$ssh-keygen -t rsa
Generatingpublic/private rsa key pair.
Enter filein which to save the key (/root/.ssh/id_rsa):
/*回车,设置默认路径*/
Enter passphrase (emptyfor no passphrase):
/*回车,设置空密码*/
Enter same passphrase again:
Your identification has been savedin /root/.ssh/id_rsa.
Yourpublic key has been saved in /root/.ssh/id_rsa.pub.
如果是root用户,则在/root/.ssh/目录下生成一个私钥id_rsa和一个公钥id_rsa.pub。
2、将id_rsa.pub 文件 写入 authorized_keys
cat id_rsa.pub >> ~/.ssh/authorized_keys
查看 /root/.ssh目录
3、装id_rsa.pub 文件发送到远程机器上
scp id_rsa.pub root@172.20.14.144:/home
cat /home/id_rsa.pub >> /root/.ssh/authorized_keys
这样ssh登录远程机器就不需要密码了。