问题
My scenario is this, I am trying to SCP from server1 to server2 and and I need to create a public_key on server1 to allow server2 access to it. How do I do this?
回答1:
Use ssh-copy-id
ssh to the server1
ssh server1
generate an ssh key on server1
ssh-keygen -t rsa
copy this the public key to the autorized keys file on server2 of user "username"
ssh-copy-id -i ~/.ssh/id_rsa.pub username@server2
logout from server1
logout
Now you can login via ssh to server2 as username (or do scp stuff) from server1 without password.
For the other direction repeat the steps but switch the servers.
来源:https://stackoverflow.com/questions/13304317/add-a-publickey-to-server-for-scp