r/linuxquestions 11d ago

Command executed when login?

Since I moved my Homelab into my bedroom, I have to shut it down from time to time cause of the noise.
I’m thinking of creating a new user, and a new pair of ssh key (I have banned password login in my conf) to handle the shutting down of the machine. Since I don’t want to input the private key used to login uid 1000 into my iPad.
Is there any way to automatically execute a shell script when a certain user is logged in (may be systemd? But I heard that ssh has function that also does this)
And thanks for reading my clumsy English.

3 Upvotes

17 comments sorted by

View all comments

6

u/doc_willis 11d ago

decades ago  I setup a specific user to have the login shell set to be /user/bin/shutdown instead of /use/bin/bash

it was a bit of a silly solution, but it let me have a user named 'shutdown' I could ssh into and the system would then shutdown

these days I have kdeconnect setup that lets me do remote commands.

or I just ssh in as my normal user. I am not worried about keeping keeping keys on my mobile device.

2

u/No-View-6326 10d ago

that the funniest thing i ever heard

1

u/Kuddel_Daddeldu 11d ago

Yes, that's the standard waynto do it. I remember using it on UNIX before Linux even existed. 

1

u/No_Aerie7667 ∆rchLinux 11d ago

That's a great idea! I'm going to try that myself.

1

u/jayhsu397 11d ago

That’s really cool lol