1/13/2013 - 3:02 AM

Copy SSH Key to Remote Server

Copy SSH Key to Remote Server

# 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


	echo "Copying local SSH Key to $1..."
	echo "Example Usage: copy-ssh-key username@hostname.com"
	cat ~/.ssh/id_rsa.pub | ssh $1 "cat - >> .ssh/authorized_keys"
	echo "Your Public SSH Key was copied to $1."


# Second Method is use the Copy Keys script available via the Repositories (Debian/Ubuntu0

  ssh-copy-id <username>@<host>