centos的key登录,关闭密码登录

1、删除机器原有的key

rm -rf /root/.ssh

2、创建key
[root@rain ~]# ssh-keygen -t rsa
一路回车

3、改名
[root@rain ~]# mv /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys

4、把key下载到本地
sz /root/.ssh/id_rsa

5、
设置crt 使用public key登录 关联此id_rsb

设置用户名为root(表示这个key是在root用户下的)

6、
如果想关闭密码登录可以
[root@rain ~]# vi /etc/ssh/sshd_config
将"PasswordAuthentication yes"修改为"PasswordAuthentication no"

7、重新加载ssh配置
[root@rain ~]# /etc/init.d/sshd reload

原文地址:https://www.cnblogs.com/itfat/p/11833354.html