- A為本地主機
- B為遠程主機
在A中生成密鑰并傳到B上。
ssh-keygen -t rsa
scp ~/.ssh/id_rsa.pub ubuntu@xxx.xxx.xx.xx:.ssh/id_rsa.pub
在B上添加A的密鑰。
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
完成。
如果出現
sign_and_send_pubkey: signing failed: agent refused operation
在A上執行:
ssh-add