1、使用ssh-keygen生成秘钥对儿
ssh-keygen -t rsa -b 4096
2、进入/root/.ssh/ 该目录
cd /root/.ssh/
3、复制id_rsa.pub文件并重命名为authorized_keys
cp id_rsa.pub authorized_keys
4、将/root/.ssh/下的id_rsa文件使用rz命令或使用winscp、filezilla等工具拷贝出来
5、修改/etc/ssh/sshd_config配置文件
vi /etc/ssh/sshd_config
修改PasswordAuthentication yes 为
PasswordAuthentication no
添加如下两行
RSAAuthentication yes
PubkeyAuthentication yes
6、重启ssh服务
service sshd restart (Centos4/5/6.x)
systemctl restart sshd (Centos 7.x)
7、使用putty xshell等工具远程登录该服务器