local ipaddress:10.47.39.7;remote ipaddress:10.47.39.8
1、生成公钥和私钥
[root@local ~]# ssh-keygen -t rsa #一路回车
2、生成完后在.ssh目录里会看全id_isa和id_rsa.pub两个文件
[root@local ~]# cd .ssh/
[root@local .ssh]# ls
id_rsa id_rsa.pub known_hosts
3、复制id_rsa.pub文件到需要登陆的远程主机的.ssh目录
[root@local .ssh]# scp id_rsa.pub root@10.47.39.8:/root/.ssh/
4、在远程主机上把id_rsa.pub文件重命名为authorized_keys
[root@remote .ssh]# mv id_rsa.pub authorized_keys
[root@remote .ssh]# ls
authorized_keys known_hosts
5、测试
[root@local ~]# ssh 10.47.39.8
Last login: Mon Dec 25 17:00:45 2017 from 10.47.39.7
[root@remote ~]#