I need to customize OpenSSH server, so that when a new SSH connection is being made to the server, it runs some command (like running a bash script). This command is supposed to "prepare" the server for the SSH connection.
So, from client side it is just a normal SSH connection: ssh user@server.com
But on the server side, it runs a command, then allows the SSH session to start.
Is this possible with OpenSSH? or do I need to write my own SSH server?
Can the same be done when SSH connection is terminated?