一、创建秘钥对
ssh-keygen -t rsa *#-t表示加密方式*
连敲三次回车
二、将公钥导入到系统
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
三、修改ssh配置文件
vim /etc/ssh/sshd_config
#禁用密码验证
PasswordAuthentication no
#启用密钥验证
RSAAuthentication yes
PubkeyAuthentication yes
四、重启ssh服务
service sshd restart #centos系统
service ssh restart #ubuntu系统
/etc/init.d/ssh restart #debian系统
Q.E.D.