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

Breaking the Limits of Relational Databases: An Analysis of Cloud-Native Database Middleware (1)

The Product Owner — Scrum’s Great Success and Failure

We are happy to announce that the joint beta has been successfully completed.

Make site images load faster-use WebP Server to seamlessly convert images to WebP without changing…

Box Model and a few CSS properties

Introduction to Big Data Processing

How To Build A Dynamic Menu In ExpressionEngine?

How To Build A Dynamic Menu In ExpressionEngine?

A Ruby Developer’s Adventures in Elixir

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

Using containerd without docker 😛

How to install docker on RHEL using Ansible role

Golang Crash Course (The language of DevOps and Cloud)

An Introduction To Kubernetes