public:it:ssh

这是本文档旧的修订版!


ssh

  • 默认安装有客户端 openssh-client, 服务端需手动安装 sudo apt-get install openssh-server;
  • 服务名 ssh,服务进程名sshd
  • 服务端配置文件 /etc/ssh/sshd_config; 客户端配置文件 /etc/ssh/ssh_config
  • 通过 key 登陆:
    • 客户端生成私钥与公钥 ssh-keygen -t rsa
    • 把公钥加到服务端的 ~/.ssh/authorized_keys文件里, 或在客户端使用命令:ssh-copy-id -i ~/.ssh/id_rsa.pub username@hostip
  • 远程使用 SSH 时,直接使用本地的 key 的方法: using ssh agent forwarding
    • 假设 A ⇒ B ⇒ C,现在要达到在 B ⇒ C 时使用 A 的 key.
    • 要求 A 的 ssh_config 开启选项 ForwardAgent
    • 要求 A 的 ssh-agent 在运行,并有 key , 可用 ssh-add -L检查, 如果没有,则添加 ssh-add yourkey
    • 要求 B 的 sshd_config开启选项AllowAgentForwarding
    • A ⇒ B 时,使用ssh -A example.com 来手动 agent forwarding;
    • 或者在配置里配置登陆 B 时自动开启 agent forwarding;
            Host example.com
              ForwardAgent yes
        * 如果在 windows 上使用 ssh 登陆到 A,然后想进行 A => B => C 的 agent forwarding, 在 ''ssh-add''这一步时会提示一个错误(忘了叫什么),stackoverflow 有个高票解答能解决此问题(也忘记了!)FIXME
  • public/it/ssh.1451707853.txt.gz
  • 最后更改: 2016/01/02 12:10
  • oakfire