I manage a bunch of laptops in my household, and while I can do most things over SSH, sometimes I just need to physically sit down at someone's logged-in desktop environment. If the user is around, I can always "Hey, come log in for me;" but sometimes they're not around, and I end up having to fiddle with /etc/shadow to set their password to mine, log in, then restore shadow.
What I'd really like is the ability to use root's password (or better yet any admin's password) to log into a desktop as any user. I've read the man pages for every pam_ library on the system, and the only one that even seems to come close to what I'm after is pam_userdb: configuring a secondary password database with all the normal users but with the administrative password; but that's still hacky.
I've looked at the configuration guides for both lightdm and gdm, and I don't see anything about this. I've briefly looked at polkit, but frankly I have no idea what that thing is doing.
Edit: "logged-in" was probably a bad way to phrase it - I meant accessing the user's full desktop environment, not just accessing a single app.
su user
as root, then start X? Do you want it locally or remotely? Maybe a VNC is what you need? Also this question – FelixJN Jun 11 '21 at 13:50sudo
for. Readman sudo sudoers
. You canssh
to the Laptop as yourself, andsudo -u otheruser command
. – waltinator Jun 11 '21 at 20:01ssh -X
can help (and using key-based login for that is a possible answer to the OP's question, as can VNC or similar remote-desktop type software), but most GUI apps misbehave if more than one instance is run by the same user at the same time....that can be a quick way to corrupt config files. – cas Jun 12 '21 at 03:50auth pam_userdb ...
beforeauth pam_unix ...
is probably the easiest way to do what you want.Either that or write your own pam module that returns true if you the root password is entered. You can either create the duplicate accounts (with the root pw) whenever you create a new account, or just create them on the fly when you need them (and optionally deleted them afterwards). Remember to use
use_first_pass
for subsequent auth modules like pam_unix. – cas Jun 12 '21 at 04:13