TransWikia.com

How to start user session (login user graphically) from CLI?

Unix & Linux Asked on November 28, 2021

We can use loginctl in modern distributions with systemctl to control the user sessions, seats etc. E.g. with it is is trivial to logout users and works on all desktop environments.

However, can I also do the reverse? I.e. I am at the login screen graphically and do have an SSH session/terminal/TTY.
Can I graphically login a user (in a specific seat,

And yes, I know I can of course auto-login a user session at boot, but this is not what I want, I want to login/unlock it interactively with the terminal.
If you need a reason for that to not call me crazy: In the use-case below I use VNC. VNC has not the best security track record and as such can (often) only use 8 characters for a password, which is quite weak.
Now, I could of course increase the security by only booting to the login screen and then unlocking the session manually by entering a user password over VNC.
Yet again, many VNC clients/servers do not support clipboard pasting (out of the box, at least), so now I cannot enter, because I use a password with 30 random characters of course.

Use case

  1. Let’s say I have a raspberry pi and login via VNC, but I do have the "autologin" option enabled (e.g. for reasons described above).
  2. I boot the device and login via VNC, as usual.
  3. Now I login via SSH (which authenticates via public keys, which is very secure and convenient compared to VNC e.g.).
  4. Now I want to unlock the session I see in VNC, with a terminal command, without doing anything on the VNC screen. As such, I want to enter something in the SSH session to unlock that other seat/session.

I hope this describes the idea/background behind the question in enough details, in order not to get any comments like “just do XY”, “what do you want to do?“ or so.

I want this question to be as broad as possible, because I think this use-case applies to any system/distro, but if you need a specific solution, consider the Rasperry Pi environment with lightdm and LXDE.

Tries

I know I can use loginctl unlock-session to unlock a session. However, in my tests that only works when the user is already logged in.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP