先在SSH Secure Shell Client利用密碼登陸自己的服務(wù)器
password.png
獲取公鑰
- Edit → settings → keys
-
選擇Generate New...
Generate.png - 選擇RSA啤誊,20后會生產(chǎn)生產(chǎn)公鑰店茶。
下載公鑰
下載公鑰到服務(wù)器 upload 后把destination的 .ssh2 改為.ssh
-
File 和 Comment 可以自己設(shè)置哀托,Passphrase 是利用公鑰時需要驗證的。
file.png
查看和轉(zhuǎn)化
- cd /etc/.ssh 查看公鑰
- ssh-keygen -i -f ssh_secure.pub >> authorized_keys
window ssh 轉(zhuǎn)換成openssh 認識的格式
修改sshd_config文件
- RSAAuthentication yes 開啟RSA驗證
- PubkeyAuthentication yes 使用公鑰驗證
修改權(quán)限
- chmod 600 /root/.ssh/authorized_keys
重新啟動
- systemctl restart sshd
使用public key 登陸
public_key.png
成功標(biāo)志
succed.png