- 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