Sub topic 6
First boot and first login
This chapter assumes you have finished the installer and rebooted. It also assumes you can use basic shell commands, edit a file in a terminal editor, and know what an IP address is. It covers what happens during the first boot, how to log in, and what to check before you change anything.
What happens at first boot
After the installer reboots, the machine runs through a fixed sequence. Knowing the sequence helps you tell where a failure happened.
- The firmware (UEFI or BIOS) finds a boot entry and starts the bootloader.
- The bootloader, usually GRUB, loads the kernel and an initial RAM disk.
- The kernel starts and hands control to
systemdas process 1. systemdmounts filesystems, brings up the network, and starts services such assshd.- A login prompt appears on the console.
If the machine does not reach a login prompt, the failure is early. A "no bootable device" message points to firmware or boot-mode problems. A GRUB prompt or a kernel panic points to the bootloader, kernel, or disk layout. Return to the boot mode and partitioning chapters in those cases.
Logging in for the first time
You have two ways in. Which one you use depends on whether the server has a network address yet.
- Console login. This is the keyboard and screen of a physical machine, the virtual console of a hypervisor, or the web console of a cloud provider. It needs no network, so it is the fallback when SSH is broken.
- SSH login. This uses the network and is how you will normally work.
Log in at the console with the user you created in the installer. The prompt looks like this:
web01 login: admin
Password:Typing the password shows no characters. That is normal.
Some images, especially cloud images, create no password at all. They install your public SSH key for a default user such as ubuntu, debian, rocky, or ec2-user. Check your provider's documentation for the exact name.
Find the address
To log in over SSH you need the server's IP address. From the console, run:
ip -br addrThe output lists each interface, its state, and its addresses. You want an interface that is UP and has an IPv4 or IPv6 address. The loopback interface lo with 127.0.0.1 does not count.
If the interface has no address, the installer may not have configured the network, or DHCP (the protocol that hands out addresses) may not have answered. The networking chapter later in this tutorial covers fixing that.
First SSH connection
From your own computer, connect:
ssh [email protected]The first time, SSH shows a host key fingerprint and asks whether to continue:
The authenticity of host '192.0.2.10 (192.0.2.10)' can't be established.
ED25519 key fingerprint is SHA256:abc123...
Are you sure you want to continue connecting (yes/no/[fingerprint])?This is a check that you are talking to the right machine and not an impostor. If you have console access, compare the fingerprint with the one on the server:
ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pubIf the two match, answer yes. SSH then stores the key in ~/.ssh/known_hosts on your computer. If the fingerprint changes later without a reason such as a reinstall, SSH warns you loudly. Do not ignore that warning.
Orient yourself before changing anything
Before you make changes, record what you have. These commands take seconds and give you a baseline for troubleshooting.
cat /etc/os-release # distribution and release
uname -r # running kernel version
hostnamectl # hostname, machine ID, virtualization type
uptime # time since boot and load average
lsblk -f # disks, partitions, filesystems, mount points
free -h # memory and swapCheck each result against what you planned:
| Command | What to confirm |
|---|---|
| `cat /etc/os-release` | The distribution and release you meant to install |
| `lsblk -f` | The partition layout and filesystem types you chose |
| `free -h` | Swap is present if you planned for it |
| `hostnamectl` | The hostname, and whether it shows the virtualization you expect |
| `ip -br addr` | An address on the interface you plan to use |
A mismatch here is cheap to fix now. It is expensive to fix after you have installed services.
Using sudo and the root account
Most installers give you one of two arrangements.
- Your user is in the
sudogroup (Debian, Ubuntu) or thewheelgroup (RHEL family), and the root account is locked or has no password. - Root has a password, and you also created a normal user, who may or may not have sudo.
Test which one you have:
id
sudo -vid lists your groups. sudo -v asks for your password and reports an error if you are not allowed to use sudo. If you see admin is not in the sudoers file, you need to use root once, from the console, to fix it. The next chapter covers creating and managing admin users in detail.
Avoid working as root for routine tasks. A typo as root has no safety net. With sudo, each privileged command is a deliberate act that is also written to the log.
Look at the first boot log
The log from the current boot is the quickest way to spot problems that did not stop the boot. Start with the errors:
journalctl -p err -b
systemctl --failedThe first command shows messages at error priority or higher since the current boot. The second lists units that failed to start. On a clean install both are usually empty or contain only harmless hardware messages, for example about firmware on a virtual machine.
You do not need to fix every line. Note anything that looks related to disks, the network, or sshd, since those affect the rest of the setup.
Common first-login problems
| Symptom | Likely cause | What to check |
|---|---|---|
| No login prompt after reboot | Wrong boot mode or bootloader not installed | Firmware boot order and boot mode; reinstall the bootloader |
| Password rejected at console | Typing error, wrong keyboard layout, or no password set | Try the layout from the installer; use rescue mode to reset the password |
| `Connection refused` over SSH | `sshd` not installed or not running | `systemctl status ssh` or `systemctl status sshd` at the console |
| `Connection timed out` over SSH | Wrong address, no route, or a firewall dropping packets | `ip -br addr`, then check the hypervisor or cloud security group |
| `Permission denied (publickey)` | The server accepts only keys and yours is not installed | Use the console, or install the key as the next chapters explain |
| Host key warning | The machine was reinstalled, or the address now belongs to another host | Compare fingerprints before removing the old entry |
For the host key warning, remove the stale entry only after you have confirmed the cause:
ssh-keygen -R 192.0.2.10A short first-login routine
Run these in order each time you bring up a new server. The rest of the tutorial builds on a machine in this state.
- Log in at the console or over SSH and confirm you are the user you expect with
whoami. - Check the release, kernel, disks, and memory with the commands above.
- Confirm the network address with
ip -br addr. - Confirm
sudoworks for your user. - Read
journalctl -p err -bandsystemctl --failed. - Do not change SSH settings yet. Keep the console session open until key login is working.
Exercise
You can log in at the console, but ssh [email protected] from your laptop times out. systemctl status ssh shows the service is active. Which two commands do you run at the console to narrow down the cause, and what does each tell you?
Show answer
Run ip -br addr to confirm the server actually has the address 192.0.2.10 on an interface that is UP. If the address is different, you were connecting to the wrong host. Run ss -tlnp to confirm sshd is listening on port 22. If both are correct, the timeout is most likely a firewall or cloud security group between your laptop and the server dropping the packets.
Exercise
Why compare the SSH host key fingerprint with the one on the server before answering yes on the first connection?
Show answer
The fingerprint identifies the server. If it matches the one you read on the console, you know you reached your server and not another machine answering at that address. Answering yes without checking gives up that protection.