SSH Logout Hanging Problem: Fixed!

For several years now I have experienced the same problem when disconnecting SSH connections to my home or office Linux servers. I noticed the problem only occurred when I was using port forwarding. If I was using Putty to open the connection, then typing logout or exit to disconnect would leave an empty Putty window open, waiting for SSH to complete the disconnection process. So I would have to manually close the window each time. No big deal.

However, this was also happening when I connected from a terminal window on another Linux machine, or more recently, on my MacBook. Here it was becoming more of an annoyance, since I would usually want to continue using that terminal window after disconnecting the SSH connection.

Earlier this week, I discovered I could ask my ISP to modify the reverse DNS zone information so that my home static IP address resolved to the same hostname that I had configured it to point to (i.e., dev82.org -> 66.92.66.105). Whenever I open an SSH connection to my home server, I always use the hostname instead of typing the IP address. The SSH connection would work, but when I disconnected it would hang. As soon as the ISP had updated the reverse DNS zone information, disconnects started working properly and the hanging stopped!

So apparently, whenever you connect via SSH to a hostname while utilizing port forwarding, the IP address must have reverse DNS setup properly (to resolve to the hostname), otherwise SSH might fail to successfully disconnect the session.

If you're having similar SSH disconnect issues, I will show you how you can check your hostname. I will use dev82.org and 66.92.66.105 as examples. The nslookup command should work on Linux, OS X, or Windows systems.

First, check what IP address your hostname resolves to:

raam@eris:~$ nslookup dev82.org

Non-authoritative answer:
Name: dev82.org
Address: 66.92.66.105

Now do the reverse to make sure Name and Address match:

raam@eris:~$ nslookup 66.92.66.106

Non-authoritative answer:
105.66.92.66.in-addr.arpa name = dev82.org.

If running nslookup on your IP address doesn't return the same name you're connecting to, then that might be the cause for your SSH disconnection problems. If your broadband connection comes with a static IP address, you should be able to call your ISP and ask them to change the hostname that your IP address resolves to.

Write a Comment

Comment

  1. This information helped me figure out the issue with my Putty Hanging on exit. I was connecting to my domain name, variux.com. When I did the reverse dns lookup it was pointing to host.variux.com. So now I just ssh to host.variux.com and it works fine.

    Thanks for the article!!

  • Related Content by Tag