Ask HN: Why is there no native SSH hook to run a local command before connecting

6 points by tetris11 ↗ HN
The `LocalCommand` parameter only runs a command on the local machine after the connection is established.

Is there no pre-connection hook?

My use case is simply that I do port knocking to expose my ssh port, and want this working automatically at the SSH config level so that I can use it transparently from other utilities (e.g. Ansible inventory, Emacs over TRAMP)

4 comments

[ 1.9 ms ] story [ 22.8 ms ] thread
Besides the ProxyCommand approach, another way would be to define 'ssh' as a shell alias/function that does the port knocking first and then passes any parameters to the normal /usr/bin/ssh.

Or you could make your own 'ssh' shell script somewhere else on the filesystem that handles it for you.

OpenSSH was written by and is still maintained by those who adhere to The Unix Way. If you asked for this feature, they would probably tell you to just use a shell alias or function instead.