reverse ssh related

Skip to first unread message

Rifo Turs

Jun 8, 2017, 3:16:16 AM6/8/17
to ISOBlue
Hello Yang,

I have been testing the reverse ssh and came across an issue.
The first time I access it everything works okey but if I exit and then try to connect it (from my PC) it usually doesn't work.

While debugging, I see that on Isoblue side, I get the below warninig
Warning: remote port forwarding failed for listen port 2222

On the PC side, I think the SSH connection is not closed propely

root@ubuntu:~# lsof -i :2222
sshd    25248 flap    9u  IPv6 1202155      0t0  TCP localhost:2222 (LISTEN)
sshd    25248 flap   10u  IPv4 1202156      0t0  TCP localhost:2222 (LISTEN)
sshd    25248 flap   11u  IPv6 1220908      0t0  TCP localhost:2222->localhost:33430 (CLOSE_WAIT)
sshd    25248 flap   12u  IPv6 1221823      0t0  TCP localhost:2222->localhost:33432 (CLOSE_WAIT)

If I kill the process and then restart isoblue, the connection starts working.

Have you came across such a case?

Maybe we can improve the reverse ssh by adding a monitoring mechanism on the isoblue side which restarts the rever ssh process if "Warning: remote port forwarding failed for listen port 2222" is spotted


Yang Wang

Jun 8, 2017, 10:36:31 AM6/8/17
to ISOBlue
Hello Rifo,

I ran into these problems before I think. It would be very helpful, especially when debugging ssh issues, to turn on the debug flag of ssh. You can run your command like this:

ssh -p 2222 -vvvv root@localhost

For your particular issue, I think the problem is that your sshd is still keeping the idle ssh port forwarding session alive. As a result, when ISOBlue still tries to port forward, it will see port 2222 is already being used. To test this, you can try supplying a different port number to see if the problem goes away. If this is the case, it would be better to edit your sshd_config file under /etc/ssh/ on your desktop.

Look for the property ClientAliveInterval and change it to some smaller value like 1. This will kill the idle ssh session pretty much right after it is in idle.

Let me know if that solves the problem.


Rifo Turs

Jun 8, 2017, 3:01:41 PM6/8/17
to ISOBlue
Hello Yang,

Once again, thank you for the detailed explanation. I will try your solution and report back.

have a nice day

8 Haziran 2017 Perşembe 17:36:31 UTC+3 tarihinde Yang Wang yazdı:
Reply all
Reply to author
0 new messages