openssh cygwin: connection closed by remote host - SSH

This is a discussion on openssh cygwin: connection closed by remote host - SSH ; Hello, I have installed OpenSSH V4.2 on a windows 98 box running cygwin so that I can log in to it remotely. I am able to do so, but I have noticed that after I log in/out say 5 or ...

+ Reply to Thread
Results 1 to 11 of 11

Thread: openssh cygwin: connection closed by remote host

  1. openssh cygwin: connection closed by remote host

    Hello,

    I have installed OpenSSH V4.2 on a windows 98 box running cygwin so
    that I can log in to it remotely. I am able to do so, but I have
    noticed that after I log in/out say 5 or so complete round trips ( by
    round trip I mean logging in then logging out), I get the following
    message when trying to log in remotely:

    ssh_exchange_identification: Connection closed by remote host

    >From then on I am not able to connect remotely until I kill sshd.exe

    and then restart it by doing so physically at the windows box. Any
    ideas on why this might be happening. My apologies if this isn't the
    correct newsgroup for this post. Thanks,

    Kevin


  2. Re: openssh cygwin: connection closed by remote host

    > Hello,
    >
    > I have installed OpenSSH V4.2 on a windows 98 box running cygwin so
    > that I can log in to it remotely. I am able to do so, but I have
    > noticed that after I log in/out say 5 or so complete round trips ( by
    > round trip I mean logging in then logging out), I get the following
    > message when trying to log in remotely:
    >
    > ssh_exchange_identification: Connection closed by remote host
    >
    > >From then on I am not able to connect remotely until I kill sshd.exe

    > and then restart it by doing so physically at the windows box. Any
    > ideas on why this might be happening.


    No, but you can get more information by connecting with ssh -v or -vv from
    the client, and also by cranking up LogLevel in sshd_config on the server -
    see sshd_config(5).

    --
    To reply by email, change "deadspam.com" to "alumni.utexas.net"

  3. Re: openssh cygwin: connection closed by remote host


    kherring wrote:

    > I have installed OpenSSH V4.2 on a windows 98 box running cygwin so
    > that I can log in to it remotely. I am able to do so, but I have
    > noticed that after I log in/out say 5 or so complete round trips ( by
    > round trip I mean logging in then logging out), I get the following
    > message when trying to log in remotely:
    >
    > ssh_exchange_identification: Connection closed by remote host
    >
    > >From then on I am not able to connect remotely until I kill sshd.exe

    > and then restart it by doing so physically at the windows box. Any
    > ideas on why this might be happening. My apologies if this isn't the
    > correct newsgroup for this post. Thanks,


    Never seen that problem, do you have any log error messages in Windows
    event viewer - application? If you are using syslog then the messages
    are in /var/log/messages.

    If there are no errors then a possible cause is the configuration of
    MaxStartups in your /etc/sshd_config, if you have it then look at the
    man page to see what it means or just try running the daemon w/o it to
    see if that solves the problem.
    --
    René Berber


  4. Re: openssh cygwin: connection closed by remote host


    René Berber wrote:
    > kherring wrote:
    >
    > > I have installed OpenSSH V4.2 on a windows 98 box running cygwin so
    > > that I can log in to it remotely. I am able to do so, but I have
    > > noticed that after I log in/out say 5 or so complete round trips ( by
    > > round trip I mean logging in then logging out), I get the following
    > > message when trying to log in remotely:
    > >
    > > ssh_exchange_identification: Connection closed by remote host
    > >
    > > >From then on I am not able to connect remotely until I kill sshd.exe

    > > and then restart it by doing so physically at the windows box. Any
    > > ideas on why this might be happening. My apologies if this isn't the
    > > correct newsgroup for this post. Thanks,

    >
    > Never seen that problem, do you have any log error messages in Windows
    > event viewer - application? If you are using syslog then the messages
    > are in /var/log/messages.
    >
    > If there are no errors then a possible cause is the configuration of
    > MaxStartups in your /etc/sshd_config, if you have it then look at the
    > man page to see what it means or just try running the daemon w/o it to
    > see if that solves the problem.
    > --
    > René Berber


    Thanks for the advice. I ran ssh with the -v option and noted the
    following:

    1) during the first several connections i got the following messages:

    OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: Applying options for *
    debug1: Connecting to blah.edu [myIP] port 22.
    debug1: Connection established.
    debug1: identity file /usr/users/myName/.ssh/identity type -1
    debug1: identity file /usr/users/myName/.ssh/id_rsa type -1
    debug1: identity file /usr/users/myName/.ssh/id_dsa type 2
    debug1: Remote protocol version 1.99, remote software version
    OpenSSH_4.2
    debug1: match: OpenSSH_4.2 pat OpenSSH*
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_3.9p1
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: server->client aes128-cbc hmac-md5 none
    debug1: kex: client->server aes128-cbc hmac-md5 none
    debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
    debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
    debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
    debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
    debug1: Host 'blah.edu' is known and matches the RSA host key.
    debug1: Found key in /usr/users/myName/.ssh/known_hosts:60
    debug1: ssh_rsa_verify: signature correct
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: SSH2_MSG_NEWKEYS received
    debug1: SSH2_MSG_SERVICE_REQUEST sent
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue:
    publickey,password,keyboard-interactive
    debug1: Next authentication method: publickey
    debug1: Trying private key: /usr/users/myName/.ssh/identity
    debug1: Trying private key: /usr/users/myName/.ssh/id_rsa
    debug1: Offering public key: /usr/users/kherring/.ssh/id_dsa
    debug1: Server accepts key: pkalg ssh-dss blen 433
    debug1: read PEM private key done: type DSA
    debug1: Authentication succeeded (publickey).
    debug1: channel 0: new [client-session]
    debug1: Entering interactive session.


    2) When the failure starts to occur, this is the message:

    OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: Applying options for *
    debug1: Connecting to rsegph1.mit.edu [18.62.8.156] port 22.
    debug1: Connection established.
    debug1: identity file /usr/users/kherring/.ssh/identity type -1
    debug1: identity file /usr/users/kherring/.ssh/id_rsa type -1
    debug1: identity file /usr/users/kherring/.ssh/id_dsa type 2
    ssh_exchange_identification: Connection closed by remote host

    does this make the problem any more obvious? I'm still stumped.
    Thanks again for any help.


  5. Re: openssh cygwin: connection closed by remote host

    > OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
    > debug1: Reading configuration data /etc/ssh/ssh_config
    > debug1: Applying options for *
    > debug1: Connecting to rsegph1.mit.edu [18.62.8.156] port 22.
    > debug1: Connection established.
    > debug1: identity file /usr/users/kherring/.ssh/identity type -1
    > debug1: identity file /usr/users/kherring/.ssh/id_rsa type -1
    > debug1: identity file /usr/users/kherring/.ssh/id_dsa type 2
    > ssh_exchange_identification: Connection closed by remote host


    Running ssh -vv or -vvv on the client will give you more information, which
    may help to illuminate what happened.

    What do the server logs show from this exchange? Did you crank up LogLevel
    to VERBOSE or DEBUG in /etc/ssh/sshd_config and restart sshd?

    --
    To reply by email, change "deadspam.com" to "alumni.utexas.net"

  6. Re: openssh cygwin: connection closed by remote host


    Andrew Schulman wrote:
    > > OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
    > > debug1: Reading configuration data /etc/ssh/ssh_config
    > > debug1: Applying options for *
    > > debug1: Connecting to rsegph1.mit.edu [18.62.8.156] port 22.
    > > debug1: Connection established.
    > > debug1: identity file /usr/users/kherring/.ssh/identity type -1
    > > debug1: identity file /usr/users/kherring/.ssh/id_rsa type -1
    > > debug1: identity file /usr/users/kherring/.ssh/id_dsa type 2
    > > ssh_exchange_identification: Connection closed by remote host

    >
    > Running ssh -vv or -vvv on the client will give you more information, which
    > may help to illuminate what happened.
    >
    > What do the server logs show from this exchange? Did you crank up LogLevel
    > to VERBOSE or DEBUG in /etc/ssh/sshd_config and restart sshd?
    >
    > --
    > To reply by email, change "deadspam.com" to "alumni.utexas.net"



    So I have noticed that upon logout from a remote session that the
    forked sshd process is not killed. So say after having logged in and
    then out 5 complete round trips there will be 6 sshd processes running
    on the remote windows box, 1 corresponding to the original and 5 forked
    processes from the 5 now closed connections. Could it be that this is
    the source of my problems? Also when running sshd in debug mode I was
    unable to open a connection, got: will not fork when running in
    debugging mode. Should I need to fork on the first and only
    connection?
    Any thoughts? If this is the problem, is there a way to force the sshd
    process for the current connection closed without disturbing the
    orignal sshd process? Thanks for any help.


  7. Re: openssh cygwin: connection closed by remote host

    > > Running ssh -vv or -vvv on the client will give you more information, which
    > > may help to illuminate what happened.
    > >
    > > What do the server logs show from this exchange? Did you crank up LogLevel
    > > to VERBOSE or DEBUG in /etc/ssh/sshd_config and restart sshd?

    >
    > So I have noticed that upon logout from a remote session that the
    > forked sshd process is not killed. So say after having logged in and
    > then out 5 complete round trips there will be 6 sshd processes running
    > on the remote windows box, 1 corresponding to the original and 5 forked
    > processes from the 5 now closed connections. Could it be that this is
    > the source of my problems?


    I don't see anything in sshd_config that relates to the number of allowed
    concurrent connections from one user, but it is strange that those old
    processes stay around, and that might be related to your problem.

    > Also when running sshd in debug mode I was
    > unable to open a connection, got: will not fork when running in
    > debugging mode. Should I need to fork on the first and only
    > connection?


    Any time someone logs into the server, it forks off a new process to handle
    the new connection. But you misunderstood me: I didn't say to run sshd in
    debug mode (sshd -d). I said to set LogLevel to VERBOSE or DEBUG in
    /etc/ssh/sshd_config, and restart sshd.

    > Any thoughts? If this is the problem, is there a way to force the sshd
    > process for the current connection closed without disturbing the
    > orignal sshd process? Thanks for any help.


    Yes, you can kill the child sshd processes without harming the parent sshd.
    Try doing that by hand before you reach 5 leftover processes, and see if
    that allows you to keep logging in.

    --
    To reply by email, change "deadspam.com" to "alumni.utexas.net"

  8. Re: openssh cygwin: connection closed by remote host


    Andrew Schulman wrote:
    > > > Running ssh -vv or -vvv on the client will give you more information, which
    > > > may help to illuminate what happened.
    > > >
    > > > What do the server logs show from this exchange? Did you crank up LogLevel
    > > > to VERBOSE or DEBUG in /etc/ssh/sshd_config and restart sshd?

    > >
    > > So I have noticed that upon logout from a remote session that the
    > > forked sshd process is not killed. So say after having logged in and
    > > then out 5 complete round trips there will be 6 sshd processes running
    > > on the remote windows box, 1 corresponding to the original and 5 forked
    > > processes from the 5 now closed connections. Could it be that this is
    > > the source of my problems?

    >
    > I don't see anything in sshd_config that relates to the number of allowed
    > concurrent connections from one user, but it is strange that those old
    > processes stay around, and that might be related to your problem.
    >
    > > Also when running sshd in debug mode I was
    > > unable to open a connection, got: will not fork when running in
    > > debugging mode. Should I need to fork on the first and only
    > > connection?

    >
    > Any time someone logs into the server, it forks off a new process to handle
    > the new connection. But you misunderstood me: I didn't say to run sshd in
    > debug mode (sshd -d). I said to set LogLevel to VERBOSE or DEBUG in
    > /etc/ssh/sshd_config, and restart sshd.
    >
    > > Any thoughts? If this is the problem, is there a way to force the sshd
    > > process for the current connection closed without disturbing the
    > > orignal sshd process? Thanks for any help.

    >
    > Yes, you can kill the child sshd processes without harming the parent sshd.
    > Try doing that by hand before you reach 5 leftover processes, and see if
    > that allows you to keep logging in.
    >
    > --
    > To reply by email, change "deadspam.com" to "alumni.utexas.net"


    So I did try killing the new sshd processes by hand and it worked. I
    can now log in as many times as I want without issue. Also I noticed
    that when I start a new connection an sshd process is created with
    parent pid = pid of the original sshd process, and also another process
    with ppid=1. So two new sshd processes are created per new connection.
    And upon logout the process with ppid=1 remains, but the other with
    parent equal to the original sshd process goes away. Is this a hint?
    If this problem can't be solved directly I'd be interested in hearing a
    way in which to kill the child sshd processes upon logout in a clean
    manner. The way in which I did it just now causes the remote terminal
    to freeze since it is logged in and its sshd process is killed before
    logging out. I have shell scripts logging in, doing stuff, and then
    logging out, numerous times so i can't really have the term freeze each
    time. Any thoughts on a solution or if not a solution for this work
    around? Thanks again.


  9. Re: openssh cygwin: connection closed by remote host

    > So I did try killing the new sshd processes by hand and it worked. I
    > can now log in as many times as I want without issue. Also I noticed
    > that when I start a new connection an sshd process is created with
    > parent pid = pid of the original sshd process, and also another process
    > with ppid=1. So two new sshd processes are created per new connection.
    > And upon logout the process with ppid=1 remains, but the other with
    > parent equal to the original sshd process goes away. Is this a hint?
    > If this problem can't be solved directly I'd be interested in hearing a
    > way in which to kill the child sshd processes upon logout in a clean
    > manner. The way in which I did it just now causes the remote terminal
    > to freeze since it is logged in and its sshd process is killed before
    > logging out. I have shell scripts logging in, doing stuff, and then
    > logging out, numerous times so i can't really have the term freeze each
    > time. Any thoughts on a solution or if not a solution for this work
    > around? Thanks again.


    OK, well that's some progress.

    The only reason I can think of that sshd processes might be left hanging
    around is if they've spawned other processes that haven't terminated yet.
    Are you starting some background tasks on each login that aren't completing
    when you log out? See if you can use pstree on the server to find any
    descendants of one of those leftover sshd processes.

    If that doesn't solve your problem, then I think you have a bug in Cygwin's
    OpenSSH server package, and you should report it as such to the Cygwin
    mailing list. Be sure to attach the output of

    cygcheck -svr

    as a text file attachment (not inline) to your message. The Cygwin police
    will jump all over you if you don't, and besides that it may be especially
    important in this case. Cygwin recently released a new version of their DLL
    (1.5.20) which is having a lot of unusual problems reported against it. If
    you're using that version your problems may be related to that.

    As for automatically killing the extra processes as a workaround, I don't
    have any ideas offhand, but I'm sure it can be done.

    Good luck,
    Andrew.

    --
    To reply by email, change "deadspam.com" to "alumni.utexas.net"

  10. Re: openssh cygwin: connection closed by remote host


    Andrew Schulman wrote:
    > > So I did try killing the new sshd processes by hand and it worked. I
    > > can now log in as many times as I want without issue. Also I noticed
    > > that when I start a new connection an sshd process is created with
    > > parent pid = pid of the original sshd process, and also another process
    > > with ppid=1. So two new sshd processes are created per new connection.
    > > And upon logout the process with ppid=1 remains, but the other with
    > > parent equal to the original sshd process goes away. Is this a hint?
    > > If this problem can't be solved directly I'd be interested in hearing a
    > > way in which to kill the child sshd processes upon logout in a clean
    > > manner. The way in which I did it just now causes the remote terminal
    > > to freeze since it is logged in and its sshd process is killed before
    > > logging out. I have shell scripts logging in, doing stuff, and then
    > > logging out, numerous times so i can't really have the term freeze each
    > > time. Any thoughts on a solution or if not a solution for this work
    > > around? Thanks again.

    >
    > OK, well that's some progress.
    >
    > The only reason I can think of that sshd processes might be left hanging
    > around is if they've spawned other processes that haven't terminated yet.
    > Are you starting some background tasks on each login that aren't completing
    > when you log out? See if you can use pstree on the server to find any
    > descendants of one of those leftover sshd processes.
    >
    > If that doesn't solve your problem, then I think you have a bug in Cygwin's
    > OpenSSH server package, and you should report it as such to the Cygwin
    > mailing list. Be sure to attach the output of
    >
    > cygcheck -svr
    >
    > as a text file attachment (not inline) to your message. The Cygwin police
    > will jump all over you if you don't, and besides that it may be especially
    > important in this case. Cygwin recently released a new version of their DLL
    > (1.5.20) which is having a lot of unusual problems reported against it. If
    > you're using that version your problems may be related to that.
    >
    > As for automatically killing the extra processes as a workaround, I don't
    > have any ideas offhand, but I'm sure it can be done.
    >
    > Good luck,
    > Andrew.
    >
    > --
    > To reply by email, change "deadspam.com" to "alumni.utexas.net"



    I solved this multiple open sshd processes problems. That issue is now
    gone. Now there is only at most 2 sshd processes ever running at the
    same time, the original parent process and a child process for the
    current remote connection. Now I have noticed that I still get this
    connection closed by remote host problem after having exactly 18 round
    trip connections. It is always 18. I changed that MaxStartups field
    in the sshd_config file, but this doesn't help anything, nor really
    should it given that has to do with concurrent connections, and these
    are orthogonal in time. My best guess is that some internal structure
    to opensshd is filling up and not refreshing itself upon log outs.
    What this is though is beyond me.


  11. Re: openssh cygwin: connection closed by remote host


    kherring@gmail.com wrote:

    >
    >
    > I solved this multiple open sshd processes problems. That issue is now
    > gone. Now there is only at most 2 sshd processes ever running at the
    > same time, the original parent process and a child process for the
    > current remote connection. Now I have noticed that I still get this
    > connection closed by remote host problem after having exactly 18 round
    > trip connections. It is always 18. I changed that MaxStartups field
    > in the sshd_config file, but this doesn't help anything, nor really
    > should it given that has to do with concurrent connections, and these
    > are orthogonal in time. My best guess is that some internal structure
    > to opensshd is filling up and not refreshing itself upon log outs.
    > What this is though is beyond me.


    And here's a story on how not to implement a new
    computer system:


+ Reply to Thread