Before I can to connect to a particular remote machine I have to run a certain local command. So instead of ssh me@remote.machine I have to dolocal_commandssh me@remote.machineI would like to automate this so that I only have to do ssh remote.machine.I know that I can achieve this at the shell level by creating my own ssh script that calls /usr/bin/ssh, but can I do it using the ProxyCommand option of ssh_config?As far as I understand it, I need something likeHost remote.machine    ProxyCommand local_command; ssh me@remote.machinein my ~/.ssh/config file, but not exactly this of course because it's circular!
Can ssh_config's ProxyCommand run a local command before connecting to a remote machine?
proxy;openssh
If using ProxyCommand, you must use something like /usr/bin/nc to connect the server.For invoking your command before connect, you need to use sh -c command list to merge the two commands as one.Host remote.machine    ProxyCommand sh -c local_command; /usr/bin/nc %h %pMORE:If your local_command is too complicated, you can use a script:cat my_connect.sh#!/bin/bashlocal_command/usr/bin/nc $1 $2The ssh config becomes:Host remote.machine        ProxyCommand /path_to_my_connect.sh %h %pAt the last, you can add your own proxy to the /usr/bin/nc