Created
June 21, 2012 22:44
-
-
Save perpetual-hydrofoil/2969071 to your computer and use it in GitHub Desktop.
Add Me
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 -e | |
# <[email protected]> | |
# 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 "[email protected]" | |
echo "Uninstalling is as easy as: sudo userdel -r jamieson" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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