Created
June 12, 2013 02:08
-
-
Save cbednarski/5762351 to your computer and use it in GitHub Desktop.
If you already have sudo, add yourself to root
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 | |
if [ $# == 1 ]; then | |
echo "adding ssh key to root on $1" | |
ssh $1 'sudo mkdir /root/.ssh/ || sudo chmod 700 /root/.ssh/' | |
cat ~/.ssh/id_rsa.pub | ssh $1 'sudo tee -a /root/.ssh/authorized_keys' | |
exit 0 | |
else | |
echo "wrong number of parameters" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment