Created
August 19, 2012 16:27
-
-
Save eddywashere/3395958 to your computer and use it in GitHub Desktop.
Ubuntu Setup (12.04)
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/sh | |
## current 1 liner | |
# wget http://url.com/ubuntu-setup.sh && chmod 700 ubuntu-setup.sh && ./ubuntu-setup.sh | |
# use raw url from github ;] | |
echo "Choose setup: user, setup, or mail" | |
read choice | |
if [ $choice = user ] | |
then | |
## user setup | |
read -p "Enter name of user : " user | |
echo "setting up user: $user" | |
adduser $user | |
groupadd admin | |
adduser $user admin | |
adduser $user sudo | |
ls -lah | |
read -p "enter path of ubuntu-setup.sh script : " install | |
mv /root/ubuntu-setup.sh /home/$user/ | |
chown $user /home/$user/ubuntu-setup.sh | |
echo "user $user is setup, and ubuntu-setup.sh file has been moved" | |
echo "you should logout and login as $user ;)" | |
elif [ $choice = setup ] | |
then | |
### from server make .ssh directory in $user home and add key | |
echo "setting up ssh" | |
mkdir ~/.ssh | |
ssh-keygen -t rsa | |
chmod 700 ~/.ssh | |
touch ~/.ssh/authorized_keys | |
chmod 600 ~/.ssh/authorized_keys | |
echo "Switch to local machine and pop a new terminal" | |
echo "do the following per pub key (don't forget semicolon at the end of remote ip)" | |
echo "scp ~/.ssh/id_dsa.pub [email protected]:" | |
echo "and/or scp ~/.ssh/id_rsa.pub [email protected]:" | |
echo "when ready hit the any key" | |
echo "reminder: script will currently only auto pull the id_dsa.pub or id_rsa.pub" | |
echo "manual way: cat ~/id_rsa.pub >> ~/.ssh/authorized_keys" | |
read anykey | |
cat ~/id_dsa.pub >> ~/.ssh/authorized_keys | |
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys | |
rm ~/id_dsa.pub | |
rm ~/id_rsa.pub | |
echo "Next step, change the sshd_config options to these values" | |
echo "PermitRootLogin no" | |
echo "PasswordAuthentication no" | |
echo "Port ##" | |
echo "AllowUsers username" | |
echo "ready to edit?" | |
read answer | |
sudo vim /etc/ssh/sshd_config | |
echo "reloading ssh" | |
sudo service ssh reload | |
echo "ssh reloaded" | |
echo "setting up firewall" | |
read -p "it enters the port set in sshd_config : " port | |
sudo ufw enable | |
sudo ufw default deny | |
sudo ufw allow $port | |
sudo ufw limit $port | |
read -p "add http/https ports? enter http, https, both or none : " web | |
if [ $web = http ] | |
then | |
sudo ufw allow 80 | |
echo "allowing http port 80" | |
elif [ $web = https ] | |
then | |
sudo ufw allow 80 | |
echo "allowing https port 443" | |
elif [ $web = both ] | |
then | |
sudo ufw allow 80 | |
sudo ufw allow 443 | |
echo "allowing http port 80" | |
echo "allowing https port 443" | |
else | |
echo "skipped" | |
fi | |
echo "firewall done" | |
echo "updating system and time" | |
sudo apt-get update | |
sudo dpkg-reconfigure tzdata | |
echo "installing git" | |
sudo apt-get install git-core curl build-essential openssl libssl-dev -y | |
echo "installing denyhosts" | |
sudo apt-get install denyhosts -y | |
echo "installing oh-my-zsh" | |
sudo apt-get install zsh -y | |
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh | |
sudo chsh -s /bin/zsh | |
read -p "Enter name of user (home/user) : " user | |
sudo chsh -s /bin/zsh $user | |
cd ~/ | |
wget -O ~/.zshrc https://raw.github.com/gist/c9723a38daeca9a21d8f/a338933dca99647fbcbe318b57c57b59233b1dcc/ubuntu-zsh | |
wget -O ~/.oh-my-zsh/themes/eddy.zsh-theme https://raw.github.com/gist/2bb7674299d309cf7242/d0417acdc3bcad0ec235dd9e78ae3a86bccd1e29/eddy.zsh-theme | |
cd ~/.oh-my-zsh/plugins/ | |
git clone git://github.com/nlevchuk/zsh-syntax-highlighting.git | |
cd | |
source ~/.zshrc | |
echo "done... but you should add in your customizations!" | |
echo "updating system packages" | |
sudo apt-get upgrade -y | |
echo "FINALLY!!! rebooting, be sure to enter port number when reconnecting" | |
sudo reboot | |
elif [ $choice = mail ] | |
then | |
echo "setting up mail" | |
sudo apt-get install postfix heirloom-mailx | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment