Skip to content

Instantly share code, notes, and snippets.

@jlafitte
Created August 25, 2014 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlafitte/cdccb3836e218fc45d72 to your computer and use it in GitHub Desktop.
Save jlafitte/cdccb3836e218fc45d72 to your computer and use it in GitHub Desktop.
Automate uploading your public ssh key to a remote system authorized keys
#!/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