Last active
August 29, 2015 14:05
-
-
Save chrcoe/65fd2c681d026849ea4a to your computer and use it in GitHub Desktop.
copy ssh pubkey to server on one line, found this @http://www.davidgrant.ca/copy_ssh_public_key_to_server_in_one_line I got tired of trying to find the link every time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat ~/.ssh/id_dsa.pub | ssh user@hostname "cat - >> ~/.ssh/authorized_keys" | |
alternative: | |
ssh user@hostname "echo `cat ~/.ssh/id_dsa.pub` >> ~/.ssh/authorized_keys" | |
here is another alternative I use on new servers (that don't already have an ~/.ssh directory: | |
cat ~/.ssh/id_dsa.pub | ssh user@hostname "mkdir ~/.ssh/; cat - >> ~/.ssh/authorized_keys" | |
*OR* | |
ssh user@hostname "mkdir ~/.ssh/; echo `cat ~/.ssh/id_dsa.pub` >> ~/.ssh/authorized_keys" | |
after this, it is necessary to set the permissions: | |
ssh user@hostname "chmod 700 ~/.ssh; chmod 640 ~/.ssh/authorized_keys" | |
or combine the first and second step if you know it's a new server: | |
cat ~/.ssh/id_dsa.pub | ssh user@hostname "mkdir ~/.ssh/; cat - >> ~/.ssh/authorized_keys; chmod 700 ~/.ssh; chmod 640 ~/.ssh/authorized_keys" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment