1. 首先在client上建立public Key和private key,需要使用ssh-keygen命令
[root@localhost .ssh]# ssh-keygen –t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): 按enter
Enter same passphrase again: 按enter
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
e8:8a:5e:ae:c7:13:45:d0:81:cd:3f:e6:1e:f8:88:5a
[email=root@localhost.localdomain]root@localhost.localdomain[/email]
2. 然后将Private Key 放在client上的宿主目录,一般放在/root/.ssh/目录中
并修改权限为user可读。
3.上述命令执行后,目录~/.ssh下会出现两个文件:id_rsa和id_rsa.pub。其中,id_rsa.pub为公钥文件。将该文件的内容追加到主机D上~/.ssh目录下的authorized_keys文件中。新建authorized_keys