Ethical Hacking

Learn to find vulnerabilities before the bad guys do! Gain real world hands on hacking experience in our state of the art hacking lab. Course designed and taught by expert instructors with years of penetration testing experience. 12 student maximum in every class. Certification attempt included in every package.
Computer Forensics Training at InfoSec Institute

Gain the in-demand skills of a certified computer examiner, learn to recover trace data left behind by fraud, theft, and cybercrime perpetrators. Discover the source of computer crime and abuse at your organization so that it never happens again. All of our class sizes are guaranteed to be 12 students or less to facilitate one-on-one interaction with one of our expert instructors.




Network Security Secure-Shell
[Top] [All Lists]

Re: how to force an ssh client timeout

Subject: Re: how to force an ssh client timeout
Date: Fri, 10 Sep 2004 16:49:57 -0700


I need to do this on the ssh client side e.g. if I
can not log into a given machine in 10 seconds
I want to terminate/close the connection and move 
on to the next machine. Please note that you may
get/establish a TCP connection to the remote server but it
may, for some reason, just stay/hang there and
you may not be able to log in

Set up in your ssh connection a local port forward.  Test
in 10 seconds if this forward is alive.  If not, kill the connection.

Here's some perl-style pseudo code:

        sub sshto {
                $host=@_;

                if ( fork ) {
                        wait
                }
                $sshpid = fork();
                if ( $sshpid ) {
                        sleep 10;
                        use IO::Socket;
                        if ( IO::Socket::INET->new(
                               Proto    => "tcp",
                               PeerAddr => "localhost",
                               PeerPort => $LOCALPORT
                         ) {
                                 exit;
                         } else {
                                 kill 9, $sshpid
                         }
                 } else {
                        exec "ssh -L $LOCALPORT:localhost:22 $SSH_ARGS $host"
                }
        }

Since the forward won't exist until ssh has logged in, you should
be able to catch if it's dead or not.


-- 
Brian Hatch                  "When I met him, he was
   Systems and                sullied and tainted.  But
   Security Engineer          now he has been purified
http://www.ifokr.org/bri/     in the fires of passion."
                              -- Bree
Every message PGP signed

Attachment: signature.asc
Description: Digital signature

<Prev in Thread] Current Thread [Next in Thread>