Autologin on Debian without Desktop Environment
Autologin is a feature that allows a user to automatically log in to their system without having to enter their username and password every time. This can be useful in situations where security is not a concern, or for systems that are used by a single user.
On Debian, autologin is typically configured through the display manager, which is responsible for managing the graphical login screen. However, if you are running Debian without a desktop environment or display manager, such as on a server or a minimal installation, configuring autologin requires a different approach.
Configuring autologin
To configure autologin on Debian without a desktop environment, you will need to modify the getty service configuration for the desired terminal.
1. Open a terminal on your Debian system.
2. Edit the /etc/systemd/system/[email protected]/override.conf file, replacing ttyX with the terminal you want to configure. For example, if you want to configure autologin for tty1, the file path would be /etc/systemd/system/[email protected]/override.conf.
3. Add the following lines to the override.conf file:
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin USERNAME --noclear %I $TERM
Replace USERNAME with the username of the user you want to automatically log in. For example, if the username is john, the line would be:
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin john --noclear %I $TERM
4. Save the file and exit the text editor.
5. Reload the systemd daemon to apply the changes by running the following command:
sudo systemctl daemon-reload
6. Restart the getty service for the terminal you configured by running the following command:
sudo systemctl restart getty@ttyX
Replace ttyX with the terminal you configured. For example, if you configured autologin for tty1, the command would be:
sudo systemctl restart getty@tty1
7. From now on, when you boot your system, it will automatically log in to the specified user account without requiring a password.
Disabling autologin
If you want to disable autologin and require a password to log in, you can simply remove or comment out the lines added to the override.conf file.
1. Open a terminal on your Debian system.
2. Edit the /etc/systemd/system/[email protected]/override.conf file, replacing ttyX with the terminal you configured.
3. Remove or comment out the following lines:
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin USERNAME --noclear %I $TERM
4. Save the file and exit the text editor.
5. Reload the systemd daemon to apply the changes by running the following command:
sudo systemctl daemon-reload
6. Restart the getty service for the terminal you configured by running the following command:
sudo systemctl restart getty@ttyX
7. Autologin will now be disabled, and you will need to enter your username and password to log in.
Configuring autologin on Debian without a desktop environment can be a useful feature for certain scenarios. By following the steps outlined in this guide, you can easily set up autologin or disable it as needed.
References
| Number | Source |
|---|---|
| 1 | Debian Wiki - Autologin without Display Manager |
| 2 | systemd Documentation |