tcp - Why is it possible to continue working in a ssh session after a network disruption?

06
2014-04
  • Ярослав Рахматуллин

    What enables the Secure Shell client and server to resume communication after one or several network interfaces in the communication path between them is shut down and re-appears some moments later? If a NIC, configured with a given IP goes down, is it not common practice to reset the connection of any clients connected to sockets on that address? TCP timeouts are one thing, but I do not quite understand how a TCP socket can be resumed after the address is "taken down".

    Actually, I realize that this is an involved question. I'm looking for answers that can help me understand what enables an OpenSSH server running on Linux 2.6+ to act as if the connection has not been severed.

    Is there more to it than mere TCP timeout? If so, what happens to the listening socket when the NIC goes down? If not, then I'd like an outline of the more sophisticated techniques employed by OpenSSH (or other services, if relevant) to keep the connection alive.

  • Answers
  • artistoex

    This is not specific to SSH server. TCP connections remain open until closed by the applications which originally opened them--regardless of forwarding table changes (which is what taking down an interface effectively represents).


  • Related Question

    openssh - How to get SSH working on Linux laptop?
  • Sasha DeTreurz

    I recently became interested in SSH, and so I attempted to set up a SSH server on my Linux laptop. I am running moonOS, a version of Ubuntu with the Enlightenment WM.

    First of all I ran "sudo apt-get install openssh-server". All fine. Now I looked at the settings for my router, and though I saw no settings explicitly called "port forwarding", there was a checkbox to enable SSH. I checked this box and set the port to 22. After this I tried "ssh localhost", and it connected fine.

    Now I checked my IP address using www.whatismyip.com, then ran PuTTY on my WinXP laptop, entering the IP address, the port, selecting SSH, etc. Then PuTTY complained that "the connection was refused". Okay. I booted a Jolicloud LiveUSB on my netbook and ran "ssh [my user name]@[my IP address]". Again, the connection was refused.

    So off I ran to the internet and looked up the documentation for OpenSSH. In a wild guess, I tried running "sshd" on the moonOS laptop, but it just replied, "sshd re-exec requires execution with an absolute path".

    Some help? I have no idea what I'm doing wrong here.


  • Related Answers
  • Ask Bjørn Hansen

    sshd re-exec requires execution with an absolute path"

    For that part, run it with a full path, for example

    /usr/sbin/sshd
    

    instead of just sshd

  • Phanto

    What type of router do you have? It would appear that you enabled SSH for your router, as opposed to forwarding port 22 to point to your laptop.

    You need to forward TCP port 22's traffic to your laptop's IP.

  • JT.WK

    Something that you should be aware of, is that for some reason many routers won't allow you to loop out and back to an internal address.

    What this means is that if both computers are on the same network, you may not be able to ssh to your public IP address, and have the port forwarded to an internal IP.

    I don't really know much about this, but I encountered this issue last week, and had to perform testing on a computer outside of my local network for success.