To get my public key onto a server I normal copy the contents of my public key, then SSH into the server, then I run vi .ssh/authorized_keys, then paste my key into the file and save.

There has got to be an easier, one step way using SCP or something like that. Of course I want to append my key to authorized_keys, not overwrite it and the permissions of authorized_keys needs to remain at 600

link|improve this question

75% accept rate
feedback

3 Answers

up vote 2 down vote accepted

You can also try this one liner:

cat ~/.ssh/id_rsa.pub | ssh user@remote-system 'umask 077; cat >>.ssh/authorized_keys'
link|improve this answer
This is perfect. Unfortunately the ssh-copy-id is not included in Mac OS X, so this one liner script will have to do and it works great. Thanks. – nvoyageur Aug 16 '10 at 14:14
feedback

I would suggest looking into the ssh-copy-id tool, ssh-copy-id -i .ssh/id_rsa remoteuser@remote.host

more on http://linux.die.net/man/1/ssh-copy-id and http://www.linuxplanet.com/linuxplanet/tips/6592/1/

link|improve this answer
feedback

ssh-copy-id is a script that will do exactly what you want: http://linux.die.net/man/1/ssh-copy-id

link|improve this answer
I feel like an idiot, not knowing this command was available on linux machines, but it's not available by default on a Mac. Thanks for the answer thought. – nvoyageur Aug 16 '10 at 14:15
feedback

Your Answer

 
or
required, but never shown

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