Created
September 3, 2014 13:27
-
-
Save chaseroden/a108fa58324cf4349cf5 to your computer and use it in GitHub Desktop.
Adds 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
#!/bin/sh | |
# ./add-key.sh <keyfile> <remote server> | |
# First argument is the key file | |
# Second argument is the server name or IP | |
# To do: check remote server to see if the key's already there first | |
scp $1 $2:.ssh/new_key | |
ssh $2 /bin/bash << EOF | |
cd .ssh | |
cp authorized_keys authorized_keys.bak | |
cat new_key >> authorized_keys | |
cat authorized_keys | |
rm new_key | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment