Looking for a one step solution to appending my SSH public key to a server's authorized_keys?
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
You can also try this one liner:
cat ~/.ssh/id_rsa.pub | ssh user@remote-system 'umask 077; cat >>.ssh/authorized_keys'
I would suggest looking into the ssh-copy-id
tool, for example:
ssh-copy-id -i .ssh/id_rsa [email protected]
More on:
-
ssh-copy-id
man page: http://linux.die.net/man/1/ssh-copy-id - OpenSSH Speed Tips and Tricks: http://www.linuxplanet.com/linuxplanet/tips/6592/1/