up vote 1 down vote favorite
1
share [g+] share [fb]

I use the following commands on computer A to generate authentication key for ssh from computer A to computer B

ssh-keygen -t rsa
scp ~/.ssh/id_rsa.pub B:.ssh/authorized_keys2

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!

link|improve this question

73% accept rate
feedback

2 Answers

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
link|improve this answer
feedback
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).

link|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
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.