Take the 2-minute tour ×


ssh-keygen -t rsa

If further I need to generate authentication keys for ssh from Computer C to Computer B, how to prevent overwriting the existing file .ssh/authorized_keys2 on B for A to B?

Thanks and regards!

share|improve this question
add comment

2 Answers

A#ssh-copy-id B
C#ssh-copy-id B

You can pass -i .ssh/some_key.pub to ssh-copy-id if you need to copy a specific pub key. authorized_keys can have multiple key entries, you are not limited to one.

If you do ssh hoping (ssh to a, then from a to b, and from b to c) it might interest you the -A argument to ssh (forwarding keys trough ssh-agent).

share|improve this answer
ssh-copy-id is just a shell script, so it makes a good reference as well. If you have if, you can use type -t ssh-copy-id (or maybe which) to see where it is, the look at it with cat/less/vim. –  Kyle Brandt Oct 27 '09 at 11:53
add comment

Upload it under a different name, e.g. .ssh/newkey, then ssh in and

cat .ssh/newkey >> .ssh/authorized_keys2

Or if you would like to be tricky and do it all in one step,

ssh user@host "cat - >> .ssh/authorized_keys2" < id_rsa.pub
share|improve this answer
add comment

Your Answer


