1. 程式人生 > >linux xshell ssh 公鑰登入

linux xshell ssh 公鑰登入

1.設定連線
這裡寫圖片描述

2.設定身份驗證
這裡寫圖片描述

3.生成公鑰
這裡寫圖片描述

這裡寫圖片描述

這裡寫圖片描述

這裡寫圖片描述

這裡寫圖片描述

最後儲存成檔案如:id_rsa_2048.pub,然後填寫生成公鑰過程中輸入的密碼
這裡寫圖片描述

4.上傳公鑰檔案到linux伺服器的~/.ssh/目錄

5.執行命令cat id_rsa_2048.pub >> authorized_keys,如果沒有authorized_keys,則自己建立一個

6.修改許可權chmod 600 authorized_keys

7.開啟之前設定的連線就可以使用公鑰連上伺服器了

8.如果其他人也需要該公鑰匙,則需要從xshell匯出私鑰檔案給其他人,然後其他人在用xshell匯入,則可以用,如果直接給其他人公鑰,xshell匯入的時候會報錯:使用者祕鑰匯入失敗
這裡寫圖片描述

這裡寫圖片描述

這裡寫圖片描述

9.禁用密碼登入
vi /etc/ssh/sshd_config
開啟:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
關掉:
PasswordAuthentication no
重啟sshd
service sshd restart