I am trying to find a way to execute a specific command when connecting to a server via SSH. By this I mean, the command will execute unconditionally on opening a connection, so this would preferably be run at the same time that a
Banner option would be printed if set. I am not trying to run a command after logging in.
What I'm after, for example:
$ ssh email@example.com (Command essentially executed at this point, before the input prints.) firstname.lastname@example.org's password:
The reason I'm trying to do this is that I would like to run a short script which sends push notifications to my phone whenever a connection is made, regardless of whether I login or not. I had planned to use pam_exec, but this only triggers
auth if a password is entered and enter is pressed, and the
session_* modules only trigger on a successful login. If a connection is opened, but then closed such as when a user simply hits Ctrl+C, then the script will never be run.
Is there any method for doing this? I'm not finding much information on the subject.