Initial Server Setup with Debian 11

We talk about about the Initial server setup with Debian 10 before. In this article, we want to teach you the Initial server setup with Debian 11.

A New Version of Debian was released and its new version 11 named “bullseye” will be supported for the next 5 years it comes with thousands of new packages and supports multiple desktop environments, driverless scanning, and an improved manual page.

Initial Server Setup with Debian 11

Let’s start our server setup with Debian 11.

How to Update and Upgrade the Debian 11

To initial server setup with Debian 11, First login into your server. Open a shell and run the following command to update the packages:

sudo apt update 

Then upgrade the packages with the following command:

sudo apt upgrade

Now it is suggested to update your distribution with the following command:

sudo apt dist-upgrade

Remove the unwanted file from your system on upgrading remove, run the following command:

sudo apt autoremove

After these, you may want to create a sudo user on your Debian 11 server.

How to create a sudo user on Debian 11

It’s better to log in as a non-root user to your server. To do this you need to add your user to sudo groups to have root privileges for executing root commands.

To create a user on Debian 11 run the following command:

sudo adduser orca

You can choose your own name. here we create “orca” as a user.

In your output you will see:

Output
Adding user `orca' ...
Adding new group `orca' (1000) ...
Adding new user `orca' (1000) with group `orca' ...
Creating home directory `/home/orca' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for orca
Enter the new value, or press ENTER for the default
        Full Name []:
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] y

after setting a password for your user, Press Enter to accept the default. then press ‘y’ to proceed.

To give sudo privileges to your new user run the following command on Debian 11 server:

sudo usermod -aG sudo orca

You can switch accounts with the following command:

sudo su orca

Here you are done with creating a sudo user on Debian 11.

How to configure the system Hostname

The hostname is what a device is called on a network.

First, you need to check your current hostname on Debian 11  server with the following command:

sudo hostnamectl

Now you can change your hostname with the following command:

sudo hostnamectl set-hostname debian11

Check that you change the hostname correctly with the following command:

hostname
Output
debian11
How to Secure SSH server on Debian 11

You need to open the SSH configuration file with your favorite editor. here we use Vi text editor. run the following command:

sudo vi /etc/ssh/sshd_config

Search the port line and uncomment it by removing the “#” and then changing the port number. For example, we change it to 6571.

Include /etc/ssh/sshd_config.d/*.conf
Port 6571
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

Then find the PermitRootLogin line uncomment it and set it to no. like this:

# Authentication:
#LoginGraceTime 2m
PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

Save and close the file.

Restart the SSH with the command below:

sudo systemctl restart ssh

Note: If you cant open this file, then the SSH server would be missing from your system. Install SSH with the following command:

sudo apt install openssh-server
How to set up a Firewall on Debian 11

On your Debian 11 server, you need to install a firewall. here you can use UFW for a basic setup of a firewall.

Run the following command to install the UFW:

sudo apt install ufw

Enable the firewall with the following command:

sudo ufw enable

At first, you should open a new ssh port on the firewall.

sudo ufw allow 6571/tcp

Now Deny the other incoming traffic use by typing this for more security:

sudo ufw default deny incoming

Allow outgoing traffic use with:

sudo ufw default allow outgoing

Reload the firewall with the command below:

sudo ufw reload

Now you can check that your firewall is active with:

sudo ufw status

After you make all of these changes on the Debian 11 server, you can reboot your system:

reboot
Conclusion

At this point, you learn about the Initial server setup with Debian 11. you can create a sudo user and configure the SSH server for its security and set up a basic firewall.

Hope you enjoy it.

Leave a Comment

Scroll to Top