ssh免密碼登錄快速配置方法
阿新 • • 發佈:2018-03-20
authorize wan AC 滿足 ogg pro 步驟 tin make 如果希望ssh公鑰生效需滿足至少下面兩個條件:
1) .ssh目錄的權限必須是700 2) .ssh/authorized_keys文件權限必須是600嘗試密碼登錄
環境需求:
兩臺Linux主機 A (192.168.3.101)和 B(192.168.3.102),如何使用主機 A 免密碼登錄 主機B ?
配置步驟:
首頁登錄主機 A ,在主機A上生成自己的ssh-keygen
ssh-agent bash ssh-keygen -t rsa ssh-add ~/.ssh/id_rsa ls -la /root
生成 .ssh 文件目錄
authorized_keys:存放遠程免密登錄的公鑰,主要通過這個文件記錄多臺機器的公鑰
id_rsa : 生成的私鑰文件
id_rsa.pub : 生成的公鑰文件
know_hosts : 已知的主機公鑰清單
1) .ssh目錄的權限必須是700 2) .ssh/authorized_keys文件權限必須是600
拷貝主機A的公鑰到主機B(拷貝需要輸入主機B的密碼)
ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected]
出現下面內容,說明添加成功
/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
[email protected]‘s password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh ‘[email protected]‘"
and check to make sure that only the key(s) you wanted were added.
嘗試密碼登錄
ssh [email protected]
如無意外,無需密碼可以直接登錄主機B中。
ssh免密碼登錄快速配置方法