0

The case

I'm used to set up automatic reverse ssh tunnels to remote computers via my server with cron.

Usually I use the following entry:

@reboot sleep 300 && ssh -MNf -R xxx22:host:22 user@server.com

I want to detect when such connection happens. I would like to have some script invoked automatically on connect event.

The problem

However because of -N option standard SSH's tools (ones I'm aware about) do not work. i.e. /etc/ssh/sshrc, ForceCommand and similar configuration features won't help me.

Question

So is there anything inside of SSH itself to help me or should I dig into greping logs/iptables/whatever to deal with the issue?

  • I don't think there is such thing inside sshd. The only thing ssh does is logging. fail2ban picks authentication failures from the error/access log. You can also tweak ssh to provide you this information, but it is probably not standard way. – Jakuje Jan 3 '16 at 12:55
  • Using strace to monitor SSH connections on Linux.blog.netspi.com/… – Ijaz Ahmad Khan Jan 3 '16 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.