HOWTO autossh and knockd
From Gentoo Linux Wiki
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
Please format this article according to the guidelines and Wikification suggestions, then remove this notice {{Wikify}} from the article
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 etablish 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.
