Initial Server Setup with Debian 12 Bookworm

In this tutorial, we want to show you an Initial Server Setup with a Newly Released Debian distro named Debian 12 Bookworm. Debian 12 LTS which is released on 10th July 2023 is a new version of Debian. It has amazing features and updated software than Debian 11.

To get more information and upgrade Debian 11 to 12, you can visit this guide on Upgrade Debian 11 to Debian 12 from Command Line.

Now follow the steps below to get an initial setup with Debian 12 Bookworm.

Initial Server Setup with Debian 12 Bookworm

In this guide, you will learn to update and upgrade your Debian 12 server, create a sudo user, configure your hostname, secure an SSH server, and set up a basic firewall with a UFW firewall.

Let’s see how to do these options on your Debian 12 Bookworm.

Step 1 – How To Update and Upgrade Debian 12 Bookworm?

To start, it is recommended to run the system update and upgrade to get the latest packages on your server. To do this, log in to your server, open a Debian terminal, and run the commands below:

# apt update 
# apt upgrade -y

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

apt dist-upgrade

And remove the unwanted packages by using the following command:

apt autoremove

Step 2 – How To Create a Sudo User on Debian 12?

It is recommended to log in to your server as a non-root user with sudo privileges to your Debian 12 Bookworm.

To create a sudo user, you can use the following command:

adduser orca

Here we named our user orca, you can use your desired name.

In your output you will see:

Output
Adding user `orca' ...
Adding new group `orca' (1000) ...
Adding new user `orca' (1000) with group `orca (1000)' ...
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 []: orca
        Room Number []: 2
        Work Phone []: 4585
        Home Phone []:
        Other []:
Is the information correct? [Y/n] y
Adding new user `orca' to supplemental / extra groups `users' ...
Adding user `orca' to group `users' ...

Answer the questions and enter y.

Then, you must add your users to the sudoers group to have the sudo privileges. To do this, run the following command on your Debian 12 terminal:

usermod -aG sudo orca

At this point, you can switch to your sudo user with the command below:

su orca

Step 3 – How To Configure Debian 12 Bookworm Server Hostname?

As you know, a hostname is what a device is called on a network. First, check your current Debian 12 hostname with the following command:

sudo hostnamectl

In your output, you should see your static hostname, machine ID, kernel, etc.

To change your Debian 12 hostname, you can use the following command:

sudo hostnamectl set-hostname debian-bookworm

Verify your hostname by using the following command:

hostname
Output
debian-bookworm

Step 4 – How To Secure SSH Server on Debian 12 Bookworm?

When you configure your server, it’s better to change the SSH port for more security.

You need to open the SSH configuration file with your favorite editor. Here we use the vi text editor:

sudo vi /etc/ssh/sshd_config

Search the port line and then change 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 and set it to no:

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

When you are done, save and close the file.

Restart the SSH with the command below:

sudo systemctl restart ssh

Note: If you can’t open this file, then the SSH server would be missing from your system. Install SSH with the following command on Debian 12:

sudo apt install openssh-server

Step 5 – How To Set up a UFW Firewall on Debian 12 Bookworm?

UFW firewall is the default firewall for Debian and Ubuntu. To set up your firewall, install UFW on Debian 12 with the command below:

sudo apt install ufw

Then, enable the UFW firewall with the following command:

sudo ufw enable

Next, you can open a port on your UFW firewall. For example, open the SSH port that you have changed by using the command below:

sudo ufw allow 6571/tcp

Reload the firewall with the command below:

sudo ufw reload

Now you can check your firewall status by using the following command:

sudo ufw status

Finally, you can reboot your Debian 12 Bookworm to apply the changes:

reboot

In future articles, we will discuss the UFW firewall on Debian 12.

Conclusion

At this point, you have learned to do an Initial Server Setup with Debian 12 Bookworm. The initial setup steps include updating and upgrading your Debian 12 server, creating a sudo user, configuring your hostname, securing an SSH server, and setting up a basic firewall with a UFW firewall.

Hope you enjoy it. Please subscribe to us on Facebook and Twitter.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!