root用户密钥登录
使用方法
生成密钥对
ssh-keygen -t rsa -b 4096 -C "[email protected]" -f /root/.ssh/sshkey -N ""存放公钥文件到对应位置并授权
cat ~/.ssh/sshkey.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys查看私钥信息复制到本地(SSH客户端所在的设备上)
cat ~/.ssh/sshkey修改VPS上SSH只接收密钥登录的参数
etc/ssh/sshd_config
PermitRootLogin prohibit-password
PasswordAuthentication no
PubkeyAuthentication yes
ChallengeResponseAuthentication norm -rf /etc/ssh/sshd_config.d/* /etc/ssh/ssh_config.d/*重启服务器后生效
reboot