修改sshd配置文件
vim /etc/ssh/sshd_config
#增加以下三項 RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys
在root目錄下創建.ssh文件夾
[root@localhost /]# mkdir .ssh
在.ssh文件夾下創建authorized_keys文件
[root@localhost /]# cd .ssh [root@localhost .ssh]# touch authorized_keys
寫入秘鑰
[root@localhost .ssh]# vim authorized_keys
修改authorized_keys執行權限
[root@localhost .ssh]# chmod 644 authorized_keys
重啟ssh服務
[root@localhost .ssh]# systemctl restart sshd