If you want to use knockd on your server and autossh on your client you get the problem that autossh is not able to knock the server before establish a new connection.
You can use a wrapper ssh script to solve this. Place this script in a path where the original ssh-binary is not and not in the $path, for example in /etc/ppp, replace $YOURSERVER and $KNOCKSEQUENCE
#/bin/bash PID=/var/run/ssh_wrapper.pid test -e $PID && kill -9 `cat $PID` ; rm $PID knock $YOURSERVER $KNOCKSEQUENCE /usr/bin/ssh $@ & echo $! > $PID
Now tell autossh to use this wrapper, and start autossh
export AUTOSSH_PATH=/etc/ppp/ssh autossh ...
At this time on every connection autossh calls the wrapper-script. The wrapper knocks the server and then call the original ssh-binary.
Created by NickStallman.net, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.