Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thelegendofbrian/1067c9373ef15c9caeb174ccb3d93189 to your computer and use it in GitHub Desktop.
Save thelegendofbrian/1067c9373ef15c9caeb174ccb3d93189 to your computer and use it in GitHub Desktop.
Ubuntu Server 16.04 Initial Setup

Ubuntu Server 16.04 Initial Setup

Update

sudo apt-get update
sudo apt-get upgrade

Install fail2ban

sudo apt-get install fail2ban

Set up SSH

mkdir /home/brian/.ssh
chmod 700 /home/brian/.ssh

Paste your public key into authorized_keys.

nano /home/brian/.ssh/authorized_keys
chmod 400 /home/brian/.ssh/authorized_keys

Edit sshd_config

sudo nano /etc/ssh/sshd_config

Limit who can SSH in and disable passwords

PermitRootLogin no
PasswordAuthentication no
AllowUsers brian@(your-ip) deploy@(another-ip)

Restart SSH

sudo service ssh restart

Setup firewall

sudo ufw allow from {your-ip} to any port 22
sudo ufw allow 80
sudo ufw allow 443
sudo ufw enable

Install Logwatch

sudo apt-get install logwatch

TODO

Edit

sudo nano /etc/cron.daily/00logwatch

by adding

/usr/sbin/logwatch --output mail --mailto [email protected] --detail high

Now let's add some color to the shell upon login

nano /home/brian/.bash_profile

Go ahead and find a nice little template to put in there, google is your friend

Then, make the command 'bash' still give us color

ln -s /home/brian/.bash_profile /home/brian/.bashrc

Configure the web files

Make a web group for people who should be able to edit the websites in /var/www

sudo groupadd web

Add yourself to the group

sudo usermod -aG web brian

Change the owner of /var/www and set the setgid bit

sudo chown brian:web -R /var/www
sudo chmod g+s /var/www

Make sure the umask is set to 0002 for /var/www

cd /var/www
umask

Further setup guides

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