Skip to content

Instantly share code, notes, and snippets.

@cbednarski
Created June 12, 2013 02:08
Show Gist options
  • Save cbednarski/5762351 to your computer and use it in GitHub Desktop.
Save cbednarski/5762351 to your computer and use it in GitHub Desktop.
If you already have sudo, add yourself to root
#!/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