先在SSH Secure Shell Client利用密码登陆自己的服务器

获取公钥
- Edit → settings → keys
-
选择Generate New...
Generate.png
- 选择RSA,20后会生产生产公钥。
下载公钥
-
下载公钥到服务器 upload 后把destination的 .ssh2 改为.ssh
-
File 和 Comment 可以自己设置,Passphrase 是利用公钥时需要验证的。
file.png
查看和转化
- cd /etc/.ssh 查看公钥
- ssh-keygen -i -f ssh_secure.pub >> authorized_keys
window ssh 转换成openssh 认识的格式

修改sshd_config文件
- RSAAuthentication yes 开启RSA验证
- PubkeyAuthentication yes 使用公钥验证
修改权限
- chmod 600 /root/.ssh/authorized_keys
重新启动
- systemctl restart sshd
使用public key 登陆

成功标志

网友评论