Created
June 20, 2013 15:16
-
-
Save og-shawn-crigger/5823652 to your computer and use it in GitHub Desktop.
Copy your ssh public key to a server from a machine that doesn't have ssh-copy-id
If you use Mac OS X or some other *nix variant that doesn't come with ssh-copy-id, this one-liner will allow you to add your public key to a remote machine so you can subsequently ssh to that machine without a password.
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_rsa.pub | ssh user@machine "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys" |
So that is a good one.. this is what I do..
#!/bin/bash
# /usr/local/sbin/copykeys symlinked from ~/
# USAGE: copykeys [email protected]
echo "Copying local SSH Key to $1..."
cat ~/.ssh/id_rsa.pub | ssh $1 "cat - >> .ssh/authorized_keys"
echo "Your Public SSH Key was copied to $1."
exit
Shawn, what do you think of that? I try to make all of my Bash and Ruby cli scripts somewhat interactive.
I like that one much better
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
might have to remove the mkdir as most servers already have a .ssh directory