ssh: how to make it drop the connection when it is not connected?

john_owens_at_yahoo.com
Date: 08/20/04

  • Next message: Ray: "Re: ssh issue?"
    Date: 19 Aug 2004 16:24:31 -0700
    
    

    I've set up a ssh tunnel that runs at startup so that I can send mail
    when I'm off-campus:

    #!/bin/sh
    # http://cg.scs.carleton.ca/~morin/misc/laptopmail/

    . /etc/rc.common

    ConsoleMessage "Starting smtptunnel"
    while [ 1 ]; do
    ssh -N -L25:mailserver:25 username@mailserver
    sleep 5
    done

    The loop should make it maintain the connection when it drops.
    Unfortunately, when it is set up and then I lose network connectivity
    (sleeping my machine and waking it back up, or leaving wireless range),
    it doesn't drop the connection; instead it maintains some sort of
    zombie connection.

    When the connection works properly, I can do the following:

    % telnet localhost 25
    Trying ::1...
    Connected to localhost.
    Escape character is '^]'.
    220 mailhost ESMTP Sendmail 8.12.11/8.12.11; Wed, 18 Aug 2004 18:\00:36
    -0700
    ^]
    telnet> close

    But when I don't have connectivity, the tunnel still appears to be
    active (even though it can't connect):

    % telnet localhost 25
    Trying ::1...
    Connected to localhost.
    Escape character is '^]'.
    ^]
    telnet> close

    What I really want is when the ssh tunnel is not "connected" (cannot
    find its destination) then it ends; right now it is just a zombie
    connection, and I have to manually kill it and restart when I get back
    into network range.

    Suggestions?

    (OS X 10.3.5, OpenSSH_3.6.1p1+CAN-2003-0693, SSH protocols 1.5/2.0,
    OpenSSL 0x0090702f)

    JDO


  • Next message: Ray: "Re: ssh issue?"

    Relevant Pages

    • LinksysBEFSR41, openssh, puTTY and telnet problem
      ... What I'm trying to do is set up a ssh tunnel through my linksys BEFSR41 (4 ... port switch router) in order to allow secure connection to a linux app ...
      (comp.security.ssh)
    • Re: Postfix refusing connections from local SMTP
      ... > Try telnet localhost 25 and see if it answers. ... Escape character is '^]'. ... Connection closed by foreign host. ... the problem persists. ...
      (comp.os.linux.security)
    • change in semantics of socket(PF_INET, SOCK_STREAM, 0)?
      ... The connection is via an ssh tunnel, ... For vncviewer, the connect is the last call in the trace. ... it long enough, the connection times out. ... Since vnc used to work before, ...
      (freebsd-questions)
    • Re: Remote protocol version??
      ... Escape character is '^]'. ... Connection closed by foreign host. ... :sandwich% telnet localhost 22 ... Connected to localhost. ...
      (comp.security.ssh)
    • Re: Two SLIME questions
      ... image over an SSH tunnel. ... slime-connect over a nonencrypted link. ... "Lisp connection closed unexpectedly: connection broken by ... Ring the bells that still can ring. ...
      (comp.lang.lisp)