Installing a Linux operating system on a headless computer requires preparing an installation medium with SSH enabled before the first boot. By modifying the installer image to include OpenSSH server packages and configuring network settings, you can access the machine via terminal once it connects to your local network. This method eliminates the need for physical peripherals during the initial setup phase.
Preparing the Installation Medium
The core challenge in headless installation is ensuring that the remote shell service starts automatically after the graphical or text-based installer finishes. Standard Ubuntu Server images often require manual intervention to enable SSH if the network configuration changes during installation. To streamline this process, you should use a modified ISO or create a custom bootable drive. First, download the standard Ubuntu Server ISO file from the official repository. You do not need the desktop environment; the server variant is lighter and defaults to a command-line interface, which is ideal for headless setups. Once downloaded, verify the checksum to ensure the integrity of the file. Next, prepare a USB drive or write the ISO to a CD/DVD. If using a USB drive, tools likedd on Linux or Rufus on Windows are effective. The critical step here is not just burning the image, but potentially injecting the necessary SSH configurations into the initramfs or the installer environment. For most modern Ubuntu releases, simply enabling the SSH service during the user creation phase of the installer is sufficient, provided you have network connectivity.
If you wish to automate this further, consider using preseed files. A preseed file allows you to answer all installer questions in advance, including setting up the root password and installing the openssh-server package automatically. This removes human interaction entirely from the installation process.
Network Configuration Before Boot
Before inserting the installation media, ensure your target machine has a stable network connection. Since you lack a monitor, you cannot easily configure Wi-Fi or complex static IP addresses through a GUI. Ethernet is strongly recommended for its reliability and simplicity. Connect the headless computer directly to your router or switch using an Ethernet cable. Verify that the DHCP server on your network is active and assigning IP addresses correctly. You will need to identify the MAC address of the network interface card (NIC) on the target machine. This can often be found on a sticker on the chassis or by checking the BIOS/UEFI settings if you have brief physical access. Once you know the MAC address, reserve a static IP address in your router’s DHCP settings. This ensures that every time the machine boots, it receives the same IP address, making it easier to locate via SSH later. Without this step, you might spend considerable time scanning your network for a new device with a changing IP.Locating the Machine on the Network
After powering on the machine with the installation media inserted, wait for the installation to complete. The duration depends on the hardware speed and the size of the installation. During this time, the machine will reboot and attempt to establish a network connection. Use a network scanning tool on your primary computer to find the new device. Tools likenmap or fing can scan your subnet for devices with open port 22, which indicates an SSH server is running. Alternatively, check your router’s connected devices list for a host with the reserved IP address or the expected hostname.
If the machine does not appear, verify the BIOS settings. Ensure that "Boot from LAN" or PXE boot is disabled if you are using a USB stick, and that the USB drive is set as the primary boot device. Some motherboards may default to attempting a network boot instead of the local media.
Establishing the First SSH Connection
Once you have identified the IP address of the newly installed system, initiate an SSH connection from your main computer. Use the username and password you defined during the installation process. If you used a preseed file, these credentials were set automatically. Run the following command in your terminal:ssh username@ip_address
Replace username with your chosen account name and ip_address with the reserved IP. You will be prompted to accept the host key fingerprint and then enter the password. Upon successful authentication, you will see a command prompt, confirming that the headless installation was successful.
From this point forward, you can manage the system entirely remotely. It is advisable to update the system immediately after logging in to ensure all security patches are applied. Run sudo apt update && sudo apt upgrade to fetch and install the latest packages.
For enhanced security and convenience, consider setting up passwordless SSH keys. This allows you to connect without typing a password each time, which is particularly useful for scripting and automated tasks. You can generate a key pair on your local machine and copy the public key to the headless server using ssh-copy-id.
Troubleshooting Common Issues
Headless installations can occasionally fail due to network timeouts or incorrect bootloader configurations. If the machine fails to boot from the installation media, check the BIOS date and time settings. An incorrect system clock can sometimes cause certificate validation errors during the installation process. If you cannot ping the machine but suspect it is powered on, try connecting a monitor temporarily to view the console output. This will reveal any error messages related to disk partitioning or network driver failures. Once resolved, you can remove the monitor and continue managing the system via SSH. Another common issue is the firewall blocking incoming connections. While the Ubuntu installer typically configures UFW (Uncomplicated Firewall) to allow SSH, verify that the rule is active. You can check the status withsudo ufw status and ensure that port 22 is listed as allowed.
For more detailed guidance on connecting to your system, refer to our guide on Connecting to Ubuntu using ssh over Ethernet. Additionally, if you encounter issues with duplicate credentials or connection hangs, consult our articles on SSH Credentials Added Twice and Troubleshooting SSH Hangs.