1、生成密钥
ssh-keygen
说明:生成密钥会在当前用户的根目录的.ssh目录下
2、在需要被免密的服务器
#以root用户为例
vim /root/.ssh/authorized_keys
添加密钥即可
3、禁止密码登录
vim /etc/ssh/sshd_config
#禁用密码验证
PasswordAuthentication no
#启用密钥验证
PubkeyAuthentication yes
4、重启ssh服务
#centos系统
service sshd restart
#ubuntu系统
service ssh restart
#debian系统
/etc/init.d/ssh restart