Quantcast
Channel: sleeplessbeastie's notes
Viewing all articles
Browse latest Browse all 770

How to automatically login user at the console

$
0
0

I have already described a straightforward way to automatically login user at the console without touching graphical user interface using Debian Wheezy, so today I will post an update for Debian Jessie as the whole process has changed considerably.

The procedure is as simple as it was before system update, the only difference is that now it depends on systemd to manage getty service. I will configure getty to automatically login as milosz user on tty3.

Copy default getty service configuration to isolate tty3 terminal.

$ sudo cp /etc/systemd/system/getty.target.wants/getty@tty{1,3}.service

Configure service to automatically login as milosz user and wait for any key before dropping to the shell (see agetty manual page).

$ sudo sed -i -e "s/\/sbin\/agetty/\0 --login-pause --autologin milosz/" /etc/systemd/system/getty.target.wants/getty@tty3.service

You can ignore this step as it is not strictly required, but for the sake of simplicity replace tty1 occurrences in the install section.

$ sudo sed -i -e "s/tty1/tty3/" /etc/systemd/system/getty.target.wants/getty@tty3.service

Reload systemd manager configuration.

$ sudo systemctl daemon-reload

Now, you can simply reboot to apply changes or kill getty process attached to the tty3 terminal to immediately take advantage of new configuration.

$ systemctl status getty@tty3.service
● getty@tty3.service - Getty on tty3
   Loaded: loaded (/etc/systemd/system/getty.target.wants/getty@tty3.service; disabled; vendor preset: enabled)
   Active: active (running) since wto 2016-05-31 14:06:49 CEST; 1h 20min ago
     Docs: man:agetty(8)
           man:systemd-getty-generator(8)
           http://0pointer.de/blog/projects/serial-console.html
 Main PID: 7884 (agetty)
   CGroup: /system.slice/system-getty.slice/getty@tty3.service
           └─7884 /sbin/agetty --noclear tty3 linux

maj 31 14:06:49 milosz-XPS-13-9343 systemd[1]: Started Getty on tty3.
$ pgrep -u root -a -f "getty.*tty"
7884 /sbin/agetty --noclear tty3 linux
8142 /sbin/agetty --noclear tty4 linux
8152 /sbin/agetty --noclear tty6 linux
8651 /sbin/agetty --noclear tty1 linux
8760 /sbin/agetty --noclear tty2 linux
$ sudo kill 7884
$ systemctl status getty@tty3.service
● getty@tty3.service - Getty on tty3
   Loaded: loaded (/etc/systemd/system/getty.target.wants/getty@tty3.service; disabled; vendor preset: enabled)
   Active: active (running) since wto 2016-05-31 15:28:54 CEST; 7s ago
     Docs: man:agetty(8)
           man:systemd-getty-generator(8)
           http://0pointer.de/blog/projects/serial-console.html
 Main PID: 9837 (agetty)
   CGroup: /system.slice/system-getty.slice/getty@tty3.service
           └─9837 /sbin/agetty --login-pause --autologin milosz --noclear tty3 linux

maj 31 15:28:54 milosz-XPS-13-9343 systemd[1]: getty@tty3.service: Service has no hold-off time, scheduling restart.
maj 31 15:28:54 milosz-XPS-13-9343 systemd[1]: Stopped Getty on tty3.
maj 31 15:28:54 milosz-XPS-13-9343 systemd[1]: Started Getty on tty3.
$ pgrep -u root -a -f "getty.*tty"
8142 /sbin/agetty --noclear tty4 linux
8152 /sbin/agetty --noclear tty6 linux
8651 /sbin/agetty --noclear tty1 linux
8760 /sbin/agetty --noclear tty2 linux
9837 /sbin/agetty --login-pause --autologin milosz --noclear tty3 linux

Now you will be automatically logged in whenever you switch to the tty3 console.

Additional notes

Read agetty manual page for additional options.

Remove created service and reload systemd manager configuration to reverse modifications.


Viewing all articles
Browse latest Browse all 770

Trending Articles