zoukankan      html  css  js  c++  java
  • OpenSSH 使用技巧

    1. 取消 OpenSSH 初次连接 yes 确认

    在脚本中有时会使用ssh进行远程连接操作,如果是第一次 ssh 连接往往会提示你是否确认连接并要求你输入yes, 才能继续。如何才能避免这个步骤呢?

    通过 .ssh/config 配置文件

    > cat >> ~/.ssh/config << EOF
    StrictHostKeyChecking no
    EOF
    

    在ssh远程时加上一个参数

    > ssh username@ip_address -p 22 -o StrictHostKeyChecking=no
    

    2.OpenSSH agent 转发

    通过 OpenSSH 的 agent 转发功能,我们可以从 A 服务器直接连接 B 服务器而不需要将私钥放在 A 服务器

    前提条件 A,B 服务器都可以通过这个私钥 连接.

    通过 .ssh/config 配置文件

    写入如下配置, 然后正常连接服务器即可

    > cat >> ~/.ssh/config << EOF
    Host example.cn
      ForwardAgent yes
    EOF
    

    命令行方式

    > ssh-add -K ~/.ssh/id_rsa
    > ssh -A root@example.cn
    
    • -A:启动 agent 转发,具体可以 man ssh

    默认 OpenSSH 是启动 agent 转的。如果不成功请检查 /etc/ssh/sshd_config 配置文件 AllowAgentForwarding 选项 及 /etc/ssh/ssh_config 文件是否有 ForwardAgent no 配置项,改为 yes 即可。

    3. OpenSSH 密钥

    通过私钥计算公钥

    > ssh-keygen.exe -f ~/.ssh/id_rsa -y 
    

    查看公钥的指纹

    > ssh-keygen.exe -f ~/.ssh/id_rsa.pub -l
    
  • 相关阅读:
    Python rindex()方法
    Python rfind()方法
    Python replace()方法
    服务器技术综述(三)
    服务器技术综述(二)
    服务器技术综述(一)
    TensorRT-优化-原理
    TensorRT-安装-使用
    TensorRT 加速性能分析
    GPU加速:宽深度推理
  • 原文地址:https://www.cnblogs.com/wglee/p/7736938.html
Copyright © 2011-2022 走看看