生成秘钥对:
ssh-keygen -t rsa
编辑sshd_config:
该路径在/etc/ssh/sshd_config
RSAAuthentication yes 开启RSA验证
PubkeyAuthentication yes 是否使用公钥验证
AuthorizedKeysFile .ssh/authorized_keys 公钥的保存位置
PasswordAuthentication no 禁止使用密码验证登录
进入生成好的密钥文件夹:
cd /root/.ssh
(包含两个文件,公钥:id_rsa.pub用于服务器校验密匙使用,私钥:id_rsa用于客户端登陆使用)
创建秘钥验证文件
touch authorized_keys
将原来的秘钥文件内容追加至已经创建好的新文件中
cat id_rsa.pub >> authorized_keys
修改秘钥文件权限:
chmod 600 /root/.ssh/authorized_keys
重启服务:
service sshd restart
然后将私钥下载下来使用即可