In ~/.ssh/config you can use the LocalCommand directive to execute a local command whenever you connect to a remote machine via SSH. But how do I execute a command when I exit an SSH connection? It seems that *.bashrc/.bash_profile* files are not sourced when connection ends or is closed.
|
|
||||
|
|
It's not specified in the question if you want this executed on the local or remote machine. It's also not specified which shell is present on either machine, so I'm assuming If you want to execute it on the remote machine, look at
You can do a test in
If you want to execute it on the local machine, create a function wrapper around
That may be too simple for your needs, but you get the idea. |
||||
|
|
You are on the right track. If the If you want to execute a remote command, then you can force
From
|
|||||
|
