Automatic login to virtual console

From Gentoo Wiki
Jump to:navigation Jump to:search
Automatic logins pose security risks. Anyone who can start the computer can get access to the operating system. Consider a BIOS password for additional security.

Gentoo supports different init systems. Each init system requires their own solution for auto-login.
All involve passing --autologin <username> to the terminal handler called agetty, but how this is done differs per init system

Automatic login for different init systems


Edit /etc/inittab as follows:

FILE /etc/inittab
c1:12345:respawn:/sbin/agetty --autologin <username> --noclear 38400 tty1 linux
c2:2345:respawn:/sbin/agetty 38400 tty2 linux
c3:2345:respawn:/sbin/agetty 38400 tty3 linux
c4:2345:respawn:/sbin/agetty 38400 tty4 linux
c5:2345:respawn:/sbin/agetty 38400 tty5 linux
c6:2345:respawn:/sbin/agetty 38400 tty6 linux


Start with the openrc-init instructions, and adapt it for auto login on the first tty as follows:

Create a file /etc/conf.d/agetty-autologin:

FILE /etc/conf.d/agetty-autologin
agetty_options="--autologin <username> --noclear"

Replace the agetty.tty1 service with one called called agetty-autologin.tty1:

root #cd /etc/init.d
root #rc-config delete agetty.tty1
root #mv agetty.tty1 agetty-autologin.tty1
root #rc-update add agetty-autologin.tty1 default


FILE /etc/systemd/system/getty@tty1.service.d/override.conf
ExecStart=-/sbin/agetty --autologin <username> --noclear %I 38400 linux

Continue with starting an X session

This is described at X without Display Manager.