Created
August 25, 2014 03:33
-
-
Save jlafitte/cdccb3836e218fc45d72 to your computer and use it in GitHub Desktop.
Automate uploading your public ssh key to a remote system authorized keys
This file contains hidden or 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
#!/bin/bash | |
echo "-- Adds your id_rsa.pub to a remote system authorized keys --" | |
echo "Usage: $0 <user>@<host>" | |
if [ -z "$1" ]; then | |
echo -n "User: " | |
read user | |
echo -n "Host: " | |
read host | |
userhost=$user@$host | |
else | |
userhost=$1 | |
fi | |
#echo "Userhost: $userhost" | |
cat ~/.ssh/id_rsa.pub | ssh $userhost "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment