DEV Community

Cover image for The minimal server setup guide.
Uddesh
Uddesh

Posted on

The minimal server setup guide.

Setting up a server could be painful especially when you are in a hurry. Also, you can't just create an instance on cloud-like AWS or GCP and put your content and serve it. A server needs to be properly set up to secure it from attacks and serve content that you want.

In this post, we will go step by step to set up the server with minimum required things or you can say the right way. So without wasting any time let's get started.

At this point, I'm assuming that you have an instance created on cloud providers like AWS, GCP, or Digital ocean.

1: SSH to your server.

$ ssh -i location/to/your/private_key username@ipv4
💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด 💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด

This command allows you to ssh or login to your server.

2: The first thing after login into the server is update and upgrade the packages.

$ sudo apt update

$ sudo apt upgrade
💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด 💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด

Run these commands respectively.

3: Now to secure your server you should always disable root login to do so run this command.

$ sudo adduser user_name
💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด 💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด

Now, this command just asks for a password and all fill the required information. The command output will look like this.

Alt Text

4: After creating the user we need to add the user to sudo group and grant permission to perform superuser tasks.

$ usermod -aG sudo user_name

// This command will switch user to newly created user.
$ su user_name
💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด 💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด

5: Now change directory to home and add your ssh key for logging in into new user.

$ cd ~

$ mkdir -p ~/.ssh

// paste your local system public key here and save.
$ sudo nano ~/.ssh/authorized_keys
💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด 💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด

6: As we added new user we should disable root login now.

$ sudo nano /etc/ssh/sshd_config
💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด 💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด

This will open a file, find the line PermitRootLogin, and change yes to no.

Alt Text

7: To see these changes in action restart the ssh demon.

$ sudo service sshd restart
💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด 💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด

That's it for setting up and securing the server quickly.

Now for better security, you should configure your firewall too.

By default, the fireball is inactive you need to activate it first.

8: to see the fireball status.

$ sudo ufw status
💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด 💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด

9: To enable fireball.

$ sudo ufw enable
💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด 💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด

10: By default, fireball rejects all requests on all ports so you have to explicitly allow the ports you want to access.

$ sudo ufw allow ssh

$ sudo ufw allow http
💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด 💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด

These are the common services you need to allow.

After allowing these two fireball status should look like this.

Alt Text

That's it. Now your server is ready, install 'nginx' or apache and start serving your content.

I hope you will find this useful. I'll be back with another post until then Goodbye.

Alt Text

Top comments (1)

💬 ชาวเน็ตแห่แชร์: uddeshjain/the minimal server setup guide on - สรุปดราม่าล่าสุด
 
horomancer profile image
horomancer •

::put on wizard hat and robes::
I ENABLE FIREBALL!