Last active
December 11, 2015 01:18
-
-
Save jcanfield/4522006 to your computer and use it in GitHub Desktop.
Copy SSH Key to Remote Server
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
# Copy SSH Keys to Remote Server (for password-less access) | |
# | |
# More information copying SSH Keys to remote servers can be found at, https://help.ubuntu.com/community/SSH/OpenSSH/Keys. | |
# Method One is to create a simple script. | |
# I typically create the script in my ~/.bin and symbolically it to my /usr/local/sbin. | |
# $ touch ~/.bin/copykeys.sh | |
# $ chmod +x ~/.bin/copykeys.sh | |
# $ nano ~/.bin/copykeys.sh | |
# $ sudo ln -s /home/yourusername/.bin/copykeys.sh /usr/local/sbin/copy-ssh-key | |
#!/bin/bash | |
echo "Copying local SSH Key to $1..." | |
echo "Example Usage: copy-ssh-key [email protected]" | |
cat ~/.ssh/id_rsa.pub | ssh $1 "cat - >> .ssh/authorized_keys" | |
echo "Your Public SSH Key was copied to $1." | |
exit | |
# Second Method is use the Copy Keys script available via the Repositories (Debian/Ubuntu0 | |
ssh-copy-id <username>@<host> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment