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