[CENTOS7 8] ssh登入時免輸入密碼
分享完整連結 //n.sfs.tw/m10549
分享連結 [CENTOS7 8] ssh登入時免輸入密碼@精讚(文章歡迎轉載,請尊重版權註明連結來源)
2019-01-19 02:15:48 By 張○○
自動程式需要進到別台機器時,沒辦法使用交談式方式輸入密碼,所以要預先交換好金鑰,這是傳統的作法[1]:
1. 產生公私金錀
2. 把公錀加到目標機器中帳號中的目錄下的 ~/.ssh/authorized_keys 中
後來發現 [網管心得]ssh keygen用法@外行中的外行提供一個方法,超級好用的,192.168.1.1是目標ip:
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.1.1's password: <==打入該主機的密碼
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.1.1'"
and check to make sure that only the key(s) you wanted were added.
錯誤排除
如果出現像這樣的錯誤:
/bin/ssh-copy-id: ERROR: failed to open ID file 'xxx/.pub': No such file or directory
/bin/ssh-copy-id: ERROR: failed to open ID file 'xxx/.ssh/id_rsa.pub': No such file or directory
/usr/bin/ssh-copy-id: ERROR: No identities found
那是因為沒有公私鑰對,請手動建立
詳細請參考相關連結
參考資料
[1] ssh keygen 免輸入密碼 https://blog.longwin.com.tw/2005/12/ssh_keygen_no_passwd/
相關連結
http://n.sfs.tw/content/index/11033
[Rocky9] 安裝node.js 18, node.js 20
原本的nodejs16在使用 quasar dev時出現錯誤,得升級成18版以上
[SSL] Could not read certificate from server.cer 的錯誤排除
在轉換ssl憑證時,出現無法讀取的錯誤,可是怎麼看憑證都很正常,該怎麼解決?
[Linux] 如何能知道我是什麼時候安裝系統的?
linux想知道什麼時候裝系統的? 不必憑記憶。
地圖填色的網站
我們想為國家填色不需要小畫家,這個網站能幫助你
[Linux] 列出所有目錄及所占空間的方法
想知道目錄下的所有目錄所占的空間大小?
[Linux] grep 排除特定字串
使用 -v 參數可以讓grep排除特定字串的方法