0

I want to run a sh script as root on Ubuntu automatically, every time a user logs in. I tried to place the script in /etc/profile.d The script is being run but is run using the account of the user not as root. Is there any method to achieve this?

Radu M.
  • 139
  • 6

1 Answers1

2

What works for me on CentOS 7 and worked in the distant past on Ubuntu is to add the line

session    optional     pam_exec.so  /etc/make_cluster_tmp

as the final line in /etc/pam.d/sshd. This is specifically for ssh logins as that is the only allowed access to the server. Add the same line to any config files you have for local access as appropriate.

doneal24
  • 851
  • 6
  • 14