添加密钥

centos等 vi ~/.ssh/authorized_keys

把公钥保存到上面文件

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB ..... 

修改ssh配置

vi /etc/ssh/sshd_config
下面2个配置必须要全对.

PasswordAuthentication no
PubkeyAuthentication yes

检查

cat /etc/ssh/sshd_config|grep Authentication