Linux 設定 免密登入 到遠端主機
[ linux 設定免密登入到遠端主機]
1,生成本地 ssh
ssh-keygen
2, 檢視ssh key
cat ~/.ssh/id_rsa.pub
3, 用ssh-copy-id將公鑰複製到遠端機器中
在控制檯執行:
ssh-copy-id -i ~/.ssh/[email protected]
// 執行完畢後,會要求你輸入密碼,輸入密碼後會看到如下提示
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed:"/Users/zhangyunfei/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/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:
// 這時,輸入密碼,成功則看到下面:
Now try logging into the machine, with:"ssh '[email protected]'" and check to make sure that only the key(s) you wanted were added.
4, 驗證可用
ssh [email protected]]
// 發現不會再提示你輸入密碼了