步骤
- 在服务器创建密钥
cd .ssh/
ssh-keygen -t rsa
- 在服务器上安装公钥
cat id_rsa.pub >> authorized_keys
- 设置文件权限
chmod 600 authorized_keys
chmod 700 ~/.ssh
- 修改配置文件,打开秘钥登录功能
vim /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication no
- 重启sshd服务
systemctl restart sshd