現場(環境): Kali Linux 套件:ssh
Step 1. 在Client端製作憑證
#ssh-keygen -t rsa
如果之前有建立過憑證。會出現Overwrite的訊息
(建議先將以前的備份起來再進行下面動作)
Step 2. 將公鑰(PubKey)上傳到伺服器
# cd /root/.ssh/
# scp id_rsa.pub root@[伺服器IP位址]:~/
Step 3. 伺服器將憑證匯入 authorized_keys
(只有這個動作再伺服器上做)
如果伺服器裏面已經有id_rsa.pub 檔案。再將檔案移入時一定要更名
# mv /root/id_rsa.pub /root/.ssh/
# cd /root/.ssh
# cat id_rsa.pub > authorized_keys
Step 4.測試連線
#ssh root@[伺服器IP位置]
出現錯誤
sign_and_send_pubkey: signing failed: agent refused operation
依照參考網址的處理方式
#eval "$(ssh-agent -s)"
#ssh-add
接著重新登入測試
可以不用密碼登入
到這邊就完成不須密碼連線遠端伺服器了。
<本篇完>
參考網址:
http://linux988.pixnet.net/blog/post/25926301-fedora%2C-centos-ssh-%E7%99%BB%E5%85%A5%E5%88%B0%E9%81%A0%E7%AB%AF-server-%E4%B8%8D%E7%94%A8%E5%AF%86%E7%A2%BC
https://chchc.me/2016/05/26/ssh%E5%87%BA%E9%94%99-sign-and-send-pubkey-signing-failed-agent-refused-operation/