Setting up a headless Linux server
Jose Chapa • May 15 2023
A headless server is a server that operates without the need for a display, keyboard, or mouse to be directly plugged in. It is commonly used for server applications that do not require a graphical interface such as web servers, email servers, file servers, and database servers. These services are usually controlled via a web GUI or SSH. In this article, we will discuss how to turn any typical computer into a headless Linux server.
Step 1: Choosing the Linux Distribution
The first step is to choose a Linux distribution. There are many Linux distributions to choose from, but the most popular ones for servers are CentOS, Ubuntu Server, and Debian. CentOS is a stable, secure, and reliable distribution that is widely used in enterprise environments. Ubuntu Server is a user-friendly and easy-to-use distribution that is well-suited for small businesses and home enthusiasts. Debian is a stable and flexible distribution that is highly customizable. We will use commands that are in line with Debian-based distributions which are the most popular. Other distributions will use a similar process with alterations to the syntax and commands.
Step 2: Download and Install the Linux Distribution
Once you have chosen a Linux distribution, you need to download and install it. You can download the ISO file of the distribution from the official website of the distribution. Make sure you select the correct architecture for your hardware (x86, ARM, RISC V, and 32 bit or 64 bit) otherwise the ISO will not be compatible at all. You can then create a bootable USB drive or DVD from the ISO file using a tool like Rufus.
This initial setup will require keyboard/mouse and display on your future server. You will also need a wired network connection initially. Once you have created the bootable drive, plug it in and turn your future server on. Boot to the bootable drive using the special boot keys found in your manufacturer’s splash screen or on their website. You can then boot your computer from the drive and follow the installation wizard to install the Linux distribution.
Step 3: Initial configuration
Once you finish the initial setup wizard to install the operating system onto your system drive, you’ll be able to remove the bootable media and reboot the computer into the operating system. Depending on your distribution, you will follow the additional configuration steps including setting up user accounts and enabling services, updates, and features. Make sure you enable SSH if prompted and take special consideration when configuring the networking.
Make sure you configure a static IP during the networking configuration. This is necessary to facilitate management and control of this device. You can also assign that IP to the device from your home router if you prefer that method or if you want to do both. Keep in mind your router assigns this based on MAC address, so if you switch between your wired and wireless NIC, you could have problems.
Step 4: SSH
You should be ready to use SSH now. Test it by using your favorite terminal on a different device and set up an SSH session. From windows command line, you can SSH with the following syntax
Alternatively, you could use the hostname instead of the IP address.
It will then prompt you for your password. It is recommended to use a normal user account instead of the root account. This way we can be careful and deliberate when issuing superuser commands.
If SSH does not work, test connectivity from your client device to your server by pinging the IP address. If it does not ping, you may need to troubleshoot the network stack on the server as well as the firewall settings in your network. If SSH is in fact not configured on the server, you can use the following command to set it up.
sudo apt install openssh-server -y
After you have SSH connectivity, you are finished! Now you can access and configure your server via SSH without the need for a keyboard, mouse, and display directly connected to it. Now you can set up a web server, a NAS, a network monitoring utility, a SIEM, or anything else from the SSH terminal. So unplug those peripherals and set up your server in a stable place preferably with a wired network connection.
Note: some computers have BIOS/UEFI configurations which stop the boot process if there’s no keyboard or no display plugged in. If this is the case, go through your BIOS/UEFI settings and disable that feature.