Thinstation / thinstation

A framework for making thin and light Linux based images for x86 based machines and thinclients.
https://www.thinstation.net/
788 stars 188 forks source link

Disable autologin #730

Closed AlexanderZhirov closed 2 years ago

AlexanderZhirov commented 2 years ago

I'm trying to manually disable autologin after downloading the distribution. The tiny configuration is selected. Edited /etc/inittab. Is it possible to disable autologin after downloading the distribution via thinstation.conf.buildtime?

SESSION_0_TYPE=sh
SESSION_0_AUTOSTART=on
NET_USE=BOTH
NET_USE_DHCP=on
NET_HOSTNAME=my_ts
NET_FILE_ENABLED=Off
NET_TELNETD_ENABLED=ON
TIME_ZONE=Europe/Moscow
NET_TIME_SERVER=us.pool.ntp.org
NET_REMOTE_ACCESS_FROM="0.0.0.0"
TFTP_BLOCKSIZE=1024
Doncuppjr commented 2 years ago

Remove the file at /build/packages/base/etc/systemd/system/display-manager.service

On Thursday, June 16, 2022, 12:15:34 AM PDT, Alexander Zhirov @.***> wrote:

I'm trying to manually disable autologin after downloading the distribution. The tiny configuration is selected. Edited /etc/inittab. Is it possible to disable autologin after downloading the distribution via thinstation.conf.buildtime?

SESSION_0_TYPE=sh SESSION_0_AUTOSTART=on NET_USE=BOTH NET_USE_DHCP=on NET_HOSTNAME=my_ts NET_FILE_ENABLED=Off NET_TELNETD_ENABLED=ON TIME_ZONE=Europe/Moscow NET_TIME_SERVER=us.pool.ntp.org NET_REMOTE_ACCESS_FROM="0.0.0.0" TFTP_BLOCKSIZE=1024

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

AlexanderZhirov commented 2 years ago

Remove the file at /build/packages/base/etc/systemd/system/display-manager.service

If I delete the file, the distribution stops downloading and is even unavailable via ssh. I just corrected a line in the file by removing authorization from the user:

#ExecStart=-/sbin/agetty -c --noclear --nohints --noissue --nohostname -a tsuser tty1 115200 linux
ExecStart=-/sbin/agetty -c --noclear --nohints --noissue --nohostname tty1 115200 linux

Now the inclusion of the distribution looks like this:

изображение

But a new problem has appeared. The bottom line is that if I do not log in to the main machine, the script for configuring the user environment /etc/thinstation.init will not work. And there are no user settings when logging in via ssh. But if I log in on the main machine, then the /etc/thinstation.init script will work and then the necessary settings files will appear in the user directory:

~  $ ssh root@192.168.1.2
root@192.168.1.2's password: 
root@192.168.1.2 ~ # ls -la
total 0
drwx------    2 root     root            40 May 31 05:59 .
drwxr-xr-x   20 root     root           480 Jun 17 09:42 ..
root@192.168.1.2 ~ # 
Connection to 192.168.1.2 closed.
 ~  $ ssh root@192.168.1.2
root@192.168.1.2 ~ # ls -la
total 4
drwxr-x---    4 root     root           160 Jun 17 09:43 .
drwxr-xr-x   20 root     root           480 Jun 17 09:42 ..
drwx------    3 root     root            80 Jun 17 09:43 .pki
-rw-r-----    1 root     root            21 Jun 17 09:43 .profile
drwx------    2 root     root            60 Jun 17 09:43 .ssh
-rw-r-----    1 root     root             0 Jun 17 09:43 .Xauthority
root@192.168.1.2 ~ # 
AlexanderZhirov commented 2 years ago

It doesn't work that way either

root@192.168.1.2 ~ # cat /etc/inittab 
# /etc/inittab init(8) configuration for BusyBox

#tty1::sysinit:-/etc/thinstation.init
::sysinit:/etc/thinstation.init

#tty1::respawn:-/sbin/agetty -c --noclear --nohints --noissue --nohostname -a root tty1 115200 linux
tty1::respawn:-/sbin/agetty -c --noclear --nohints --noissue --nohostname tty1 115200 linux
tty2::askfirst:/sbin/getty tty2 115200 linux
tty3::askfirst:/sbin/getty tty3 115200 linux

tty1::shutdown:/bin/shutdown

::ctrlaltdel:/sbin/reboot
Thinstation commented 2 years ago

I should delete inittab, but sometimes I switch back to the old init. It's vestigial.

AlexanderZhirov commented 2 years ago

I should delete inittab, but sometimes I switch back to the old init. It's vestigial.

Are you still going to work on it?

Thinstation commented 2 years ago

Nah, inittab is dead, you can remove it.

The user home is populated on first login. If you need it to exist without login, you will need to make another service to do that, or just include a prepopulated home in your image.

AlexanderZhirov commented 2 years ago

The user home is populated on first login. If you need it to exist without login, you will need to make another service to do that, or just include a prepopulated home in your image.

So, is it possible to implement automatic filling when connecting via ssh? There, like, dropbear is. Can he do that?

Thinstation commented 2 years ago

Yes. You will need to copy base/etc/pam.d/login to ssh, that should work.

Thinstation commented 2 years ago

Maybe, login has a call to pamhooks, which calls /sbin/session, which makes the home, but it also kills processes on the way out(logoff).

AlexanderZhirov commented 2 years ago

Yes. You will need to copy base/etc/pam.d/login to ssh, that should work.

Copied to base/etc/pam.d/ssh - does not work. Or was it necessary to copy it to the wrong place?

AlexanderZhirov commented 2 years ago

I think that PAM authentication somehow does not work properly dropbear. I understand the correct file should be called /etc/pam.d/sshd, but even that doesn't work.

AlexanderZhirov commented 2 years ago

I built this source code with the --enable-pam key still doesn't work.

Thinstation commented 2 years ago

Maybe try openssh instead of sshd/dropbear package.

AlexanderZhirov commented 2 years ago

I have figured out this issue. In general. Initially, the root directory does not exist after downloading the distribution. By default, dropbear accesses ~/.ssh/authorized_keys, that is, the path specified is fixed. Therefore, at the time of authorization via dropbear, this directory with keys does not yet exist, so authorization is not possible.

In the case of openssh, it is necessary to specify in the sshd_config the path to the "non-existent" directory with keys:

AuthorizedKeysFile  /etc/skel/.ssh/authorized_keys

And, as you indicated, need to copy /etc/pam.d/login to /etc/pam.d/sshd.

And finally changes to the service build/packages/base/etc/systemd/system/display-manager.service:

ExecStart=-/sbin/agetty -c --noclear --nohints --noissue --nohostname tty1 115200 linux

Now, in this case, authorization is successfully performed and the root directory is created.

The only thing that had to be corrected and that I think needs to be fixed in the repository: After installing the openssh package, you need to move build/packages/openssh/sbin/sshd to build/packages/openssh/bin/sshd, since the systemd service runs from the bin directory, and therefore I don't have the service was being launched. I had to rule the path with my hands. Please correct this point in this package.

You were right, openssh solves the problem of disabling autologin.