ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user//.ssh/id_rsa): /home/user//.ssh/id_rsa_test
Enter passphrase (empty for no passphrase): #这里不输入任何密码
Enter same passphrase again: #这里不输入任何密码
Your identification has been saved in /home/user//.ssh/id_rsa_test.
Your public key has been saved in /home/user//.ssh/id_rsa_test.pub.
The key fingerprint is:
e3:71:f3:23:bb:1a:a1:c7:da:0b:f5:43:59:e6:5a:f3 user@master
3.把公钥拷贝到slave端:
scp /home/user/.ssh/id_rsa_test.pub testuser@slave.test.com:/home/testuser
4.登录salve端:
把文件拷贝到家目录下 .ssh目录
家目录所在位置 可以用 env | grep ‘HOME’ 查询
cat /home/testuser/id_rsa_test.pub >> /home/testuser/.ssh/authorized_keys