TTY Autologin: Difference between revisions
(Add note for setting permission bit for script) |
Prabuanand (talk | contribs) m (added category) |
||
Line 53: | Line 53: | ||
* [https://busybox.net/downloads/BusyBox.html#getty Busybox getty arguments] | * [https://busybox.net/downloads/BusyBox.html#getty Busybox getty arguments] | ||
* [https://github.com/util-linux/util-linux/blob/master/term-utils/agetty.8.adoc agetty(8) Manual Page] | * [https://github.com/util-linux/util-linux/blob/master/term-utils/agetty.8.adoc agetty(8) Manual Page] | ||
[[Category:Display Managers]] | |||
[[Category:Desktop]] |
Latest revision as of 04:05, 24 September 2024
By using agetty
How
Install agetty:
# apk add agetty
Edit /etc/inittab to use agetty
Example for the virtual terminal tty1:
tty1::respawn:/sbin/agetty --autologin root tty1 linux
Example inittab entry for a serial terminal on ttys01:
ttyS0::respawn:/sbin/agetty --autologin root ttyS0 vt100
By making your own autologin wrapper
How
- Writing a wrapper script, called autologin, around /bin/login and moving it in /usr/sbin/
- Editing /etc/inittab specifying the use of /usr/sbin/autologin instead of /bin/login
Writing the autologin script
Edit and create the script in this example in the location /usr/sbin/autologin:
Contents of /usr/sbin/autologin
Remember to make the scripts executable:
# chmod +x /usr/sbin/autologin
The script executes the login binary (part of busybox) which will be searched in $PATH.
As parameters are passed:
- -f flag which stands for "Do not authenticate (user already authenticated)"
- username in this example is root but if you created a new user, its username can be used instead.
Editing /etc/inittab
Open /etc/inittab
replace ":respawn:/sbin/getty" with ":respawn:/sbin/getty -n -l /usr/sbin/autologin" for each TTY you want to enable autologin.
- The getty's -n flag do not prompt the user for a login name
- The getty's -l flag invokes a custom login instead of /bin/login; in our case it is set to invoke /usr/sbin/autologin
Note
To perform such a replacement on all TTYs, the following command can be used:
# sed -i 's@:respawn:/sbin/getty@:respawn:/sbin/getty -n -l /usr/sbin/autologin@g' /etc/inittab
- "@" is used as a delimiter
- The -i flag edits the file in-place