TTY Autologin: Difference between revisions
Prabuanand (talk | contribs) m (fixed heading levels and points, added greetd and moved note) |
Prabuanand (talk | contribs) m (fixed the sentence) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
This page documents how to setup autologin to tty. Once configured, when computer is powered on, you will be logged in automatically without typing password. Note that, if someone else starts up your computer, they will be able to access your account and your personal data. | This page documents how to setup autologin to tty. Once configured, when computer is powered on, you will be logged in automatically without typing password. Note that, if someone else starts up your computer, they will be able to access your account and your personal data. | ||
== By using agetty== | == By using agetty == | ||
Install {{pkg|agetty}}: {{cmd|# apk add agetty}} | Install {{pkg|agetty}}: {{cmd|# apk add agetty}} | ||
Edit {{path|/etc/inittab}} to use agetty<br> | Edit {{path|/etc/inittab}} to use agetty<br> | ||
Example for the virtual terminal tty1:<br> | Example for the virtual terminal tty1:<br> | ||
Line 11: | Line 12: | ||
<code>ttyS0::respawn:/sbin/agetty --autologin root ttyS0 vt100</code> | <code>ttyS0::respawn:/sbin/agetty --autologin root ttyS0 vt100</code> | ||
{{tip|You can change the `tty1` or `ttyS0` to a different serial port or virtual terminal as you please. `root` can be changed to a different user as well. Finally the terminal type (`linux` and `vt100` in our examples) can be changed to a wide variety of serial terminals.}} | {{tip|You can change the `tty1` or `ttyS0` to a different serial port or virtual terminal as you please. `root` can be changed to a different user as well. Finally the terminal type (`linux` and `vt100` in our examples) can be changed to a wide variety of serial terminals.}} | ||
{{Note| If using [[Proxmox]], follow the [[Proxmox#Using agetty in proxmox|steps]] to enable autologin with agetty.}} | |||
== By making your own autologin wrapper == | == By making your own autologin wrapper == |
Latest revision as of 13:06, 13 March 2025
This page documents how to setup autologin to tty. Once configured, when computer is powered on, you will be logged in automatically without typing password. Note that, if someone else starts up your computer, they will be able to access your account and your personal data.
By using agetty
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
Create a script, called autologin, around /bin/login and moving it in /usr/sbin/ and editing /etc/inittab to specify the use of /usr/sbin/autologin instead of /bin/login.
- Create and edit the autologin wrapper script /usr/sbin/autologin as follows:
Contents of /usr/sbin/autologin
#!/bin/sh exec login -f root - 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.
- Open /etc/inittab and 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
- 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
Use greetd
The Greetd display manager has a text based greeter that can be configured to autologin.