Automatic login to virtual console

From Gentoo Wiki
Jump to: navigation, search
Warning
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

sysvinit

Edit /etc/inittab as follows:

FILE /etc/inittab
# TERMINALS
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

openrc-init

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

systemd

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

Continue with starting an X session

This is described at X without Display Manager.