[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
[Linux] 如何能知道我是什麼時候安裝的?
linux想知道什麼時候裝系統的?
地圖填色的網站
我們想為國家填色不需要小畫家,這個網站能幫助你
[Linux] 列出所有目錄及所占空間的方法
想知道目錄下的所有目錄所占的空間大小?
[Linux] grep 排除特定字串
使用 -v 參數可以讓grep排除特定字串的方法
git為什麼pull會失敗?
git pull為何會失敗,出現Aborting...?
解決nginx server reached pm.max_children setting的問題
這近建置的 docker+php8+nginx 運作一段時間後就壞掉了,查看log出現max_children錯誤,怎麼解決?