Skip to content

Instantly share code, notes, and snippets.

@perpetual-hydrofoil
Created June 21, 2012 22:44
Show Gist options
  • Save perpetual-hydrofoil/2969071 to your computer and use it in GitHub Desktop.
Save perpetual-hydrofoil/2969071 to your computer and use it in GitHub Desktop.
Add Me
#! /bin/sh -e
# <jamieson@jamiesonbecker.com>
# as this is designed to be run via wget, user input is not available
echo "Creating jamieson.."
# check for Linux platforms
if [ "x$(uname -a|grep -i linux)" == "x" ]; then
echo "Sorry, this works on Linux platforms only."
exit 1
fi
# add jamieson as a user
sudo useradd -m jamieson
echo "Install public key.."
# create .ssh in my home directory
sudo mkdir -p /home/jamieson/.ssh/
# install my ssh public key
sudo su - -c "echo 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAxcy26m+otQHydnBAd6F5pqSCRxXGgSfvKh+v9gWPrFp8d8qCr50IFnKCU3VlaY5unSj8VQGRw23CFBq9yYQjf7F4NwMESstjCp6lEntMkbYjnDLP5AS3ZFJjzh5ghAYOyOoAqE4f+m64iu3HbH6bv60JB8xlHY5iZBD8LJHTSoE= jamieson@x200t' > /home/jamieson/.ssh/authorized_keys"
# because this was done as root, change ownership back to me
# or else SSH won't let me log in
# note that this might fail on Linux distributions (such as SUSE) that don't
# automatically create a group for each user
sudo chown -R jamieson:jamieson /home/jamieson/
echo "Adding to sudoers.."
sudo su - -c "echo \"jamieson ALL=NOPASSWD: ALL\" >> /etc/sudoers"
echo "Trying to send an email.."
ifconfig | /usr/sbin/sendmail "jamieson@jamiesonbecker.com"
echo "Uninstalling is as easy as: sudo userdel -r jamieson"
@perpetual-hydrofoil
Copy link
Author

After thoroughly reviewing above code, this will create a user account, ADD ME TO SUDOERS, and set up my public key:

wget -O- https://raw.github.com/gist/2969071/bca1a3c5b7ec6a79978648f80f2328ad2fe6b511/add_jamieson.sh | sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment