0

I have set up the /etc/systemd/system/rc-local.service as follows:

[Unit]
 Description=/etc/rc.local Compatibility
 ConditionPathExists=/etc/rc.local

[Service]
 Type=forking
 ExecStart=/etc/rc.local start
 TimeoutSec=0
 StandardOutput=tty
 RemainAfterExit=yes
 SysVStartPriority=99

[Install]
 WantedBy=multi-user.target

The rights are set up properly on the /etc/rc.local script:

File: /etc/rc.local
...
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)

The service (hence the rc.local script) is started successfully every time the machine starts up.

However, the script does not get run every time a user logs in via ssh.

What am I missing? I'm starting to believe that I have the concept wrong.

E. Jaep
  • 137
  • 5
  • 2
    Yes, you have the concept wrong. The easiest way to do what you want may be to modify `/etc/pam.d/ssh` (filename may vary) and add a line like `session optional pam_exec.so /etc/rc.local`. – doneal24 Jun 22 '23 at 13:48
  • If a user logs in three times simultaneously, do you want three instances of the service running? If not, you need to put in some kind of locking mechanism. – doneal24 Jun 22 '23 at 13:52
  • @doneal24 Thanks for the pointer about the concept. I actually fixed by using a `/etc/profile.d/` script – E. Jaep Jun 22 '23 at 14:18

1 Answers1

1

There was a confusion between rc.local use case and using a script in /etc/profile.d

E. Jaep
  • 137
  • 5