How to Set Up Your First Ubuntu 16.04 Server on Alibaba Cloud

Prerequisites

Step 1: Connect to Your Alibaba Cloud Ubuntu 16.04 Server

Step 2: Change the Hostname on Your Ubuntu 16.04 Server

$ sudo apt-get update
$ sudo apt-get upgrade -y
$ hostname
$ sudo nano /etc/cloud/cloud.cfg
preserve_hostname true
$ sudo nano /etc/hostname
$ sudo nano /etc/hosts
127.0.0.1 localhost
127.0.1.1 miami
111.111.111.111 miami
$ sudo reboot

Step 3: Configure Time Zone on Your Ubuntu 16.04 Server

$ timedatectl
$ sudo timedatectl set-timezone
$ sudo timedatectl set-timezone Europe/London
$ date

Step 4: Create a Non-Root User with Sudo Privileges on Ubuntu 16.04

$ sudo adduser
$ sudo adduser james
$ sudo usermod -aG sudo james

Step 5: Creating Authentication Key Pair for Logging onto Your Ubuntu 16.04 Server

$ mkdir ~/.ssh
$ nano ~/.ssh/authorized_keys
$ chmod 700 -R ~/.ssh && chmod 600 ~/.ssh/authorized_keys

Step 6: Disable Password Authentication

$ sudo nano /etc/ssh/sshd_config
PasswordAuthentication no
$ sudo service ssh restart

Step 7: Disable SSH Root Access on Your Ubuntu 16.04 Server

$ sudo nano /etc/ssh/sshd_config
PermitRootLogin no
$ sudo service ssh restart

Step 8: Install a Firewall on Your Ubuntu 16.04 Server

$ sudo apt-get install ufw
$ sudo ufw default deny incoming
$ sudo ufw default allow outgoing
$ sudo ufw allow
$ sudo ufw allow 22
$ sudo ufw allow ssh
$ sudo ufw allow http
$ sudo ufw allow https
$ sudo ufw enable
$ sudo ufw status numbered
$ sudo ufw delete
$ sudo ufw disable
$ sudo ufw reset

Step 9: Install Fail2Ban on Your Ubuntu 16.04 Server

$ sudo apt-get install fail2ban
$ sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
$ sudo nano /etc/fail2ban/jail.local

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store