想要从a@HostA ssh 到 b@HostB 而不需要输入密码
这需要使用密钥
首先需要一个密钥对,不要输入passphrase. (如果已经之前生成了就可以直接用)
a@A:~> ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/a/.ssh/id_rsa): Created directory '/home/a/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/a/.ssh/id_rsa. Your public key has been saved in /home/a/.ssh/id_rsa.pub. The key fingerprint is: 3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
2. 私钥文件放到用户a@HostA的 ~/.ssh/id_rsa文件,这也是ssh-keygen 生成文件的缺省位置
3. 将公钥的内容添加到b@HostB的 .ssh/authorized_keys 文件中
完成!