How to Set Up Your First Debian 9 Server on Alibaba Cloud

Prerequisites

  1. A valid Alibaba Cloud account. If you don’t have one already, sign up to the Free Trialto enjoy up to $300 worth in Alibaba Cloud products.
  2. An ECS instance running Debian 9. You can select your preferred region and configurations; this will not affect the outcome of the server setup.
  3. A root password for your server.

Step 1: Connect to Your Alibaba Cloud Debian 9 Server

Step 2: Change the Hostname on Your Debian 9 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 Debian 9 Server

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

Step 4: Create a Non-Root User with Sudo Privileges on Debian 9

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

Step 5: Creating Authentication Key Pair for Logging onto Your Debian 9 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 Debian 9 Server

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

Step 8: Install a Firewall on Your Debian 9 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 Debian 9 Server

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

Conclusion

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Pfizer and BioNTech Conclude Phase 3 Study of COVID-19

Linux Rugged Tablet

Switched to Windows from Linux

Developing a log processing pipeline on Amazon Web Services

Top Requests by Network

Kolibri v0.12 is out!

An Absolute Beginner Guide to Mockito with Spring

Free Trials — the Key to Successful Cloud Computing

What Is NAS (Network Attached Storage)?

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
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

Kubernetes Architecture from 10,000 feet

Why is Containerization Taking Over?

Cloud Computing Trends

The Bridge Network Driver | Networking in Docker #6