先在SSH Secure Shell Client利用密碼登陸自己的服務(wù)器

password.png
獲取公鑰
- Edit → settings → keys
-
選擇Generate New...
Generate.png - 選擇RSA,20后會(huì)生產(chǎn)生產(chǎn)公鑰。
下載公鑰
下載公鑰到服務(wù)器 upload 后把destination的 .ssh2 改為.ssh
-
File 和 Comment 可以自己設(shè)置,Passphrase 是利用公鑰時(shí)需要驗(yàn)證的。
file.png
查看和轉(zhuǎn)化
- cd /etc/.ssh 查看公鑰
- ssh-keygen -i -f ssh_secure.pub >> authorized_keys
window ssh 轉(zhuǎn)換成openssh 認(rèn)識(shí)的格式

修改sshd_config文件
- RSAAuthentication yes 開啟RSA驗(yàn)證
- PubkeyAuthentication yes 使用公鑰驗(yàn)證
修改權(quán)限
- chmod 600 /root/.ssh/authorized_keys
重新啟動(dòng)
- systemctl restart sshd
使用public key 登陸

public_key.png
成功標(biāo)志

succed.png

