I am trying to run a command/script that requires root privileges when a non-root user logs into ssh
This unfortunately means I cannot use ~/.bashrc
or /etc/bashrc
I also tried /etc/ssh/sshrc
but it has the same problem, the command executes as the logged in user.
I see /etc/profile.d/
does something but not sure how to use it or if it will have the same problem.
sshd does run as root so I am hoping it can be taught to do this somehow
I do need to know the ip of the login for the command.
Thanks for any ideas!
added: sudo is not possible because it's for a non-privileged user without sudo rights
Best Answer
Use
pam_exec
as a PAM session module.