How to Set Up Your First CentOS 7 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 CentOS 7. 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 CentOS 7 Server

Step 2: Change the Hostname on Your CentOS 7 Server

$ sudo yum update
$ hostname
$ sudo yum install nano
$ 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 CentOS 7 Server

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

Step 4: Create a Non-Root User with Sudo Privileges on CentOS 7

$ sudo adduser
$ sudo adduser james
$ sudo passwd james
$ sudo gpasswd -a james wheel

Step 5: Create Authentication Key Pair for Logging onto Your CentOS 7 Server

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

Step 6: Disable Password Authentication on Your CentOS 7 Server

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

Step 7: Disable SSH Root Access on Your CentOS 7 Server

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

Step 8: Install a Firewall on Your CentOS 7 server

$ sudo yum 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 CentOS 7 Server

$ sudo yum 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

Alibaba Cloud File Storage NAS — Part 2: Use Case Scenarios and Comparison

Part 1. Authentication and sign-in BLoC

Preparation toward running Docker on ARM Mac: Building multi-arch images with Docker BuildX

WebRTC in a Nutshell (Ep-III)

Create your first application with Java and OrientDB!

Programming ATTiny85 with Arduino as ISP (ATTinyCore)

7 Things to Look For in a Custom Software Development Company | Digital Maelstrom

TreeMapping in Java !

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

Deploy with AWS CodeDeploy from GitHub

Blockchain Technology: 10 Things You Should Know.

Standalone within Docker container

Networking — HTTP