4

Using the command ssh -v -R 2255:localhost:2255 root@example.com I was trying to figure out why remote port forwarding wasn't working until I realized GatewayPorts yes was not present in my host's sshd_config. Once I added that, it worked successfully.

Is there a way I could have diagnosed this?

The SSH even output the following (without GatewayPorts yes):

debug1: Remote connections from LOCALHOST:2255 forwarded to local address localhost:2255
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: remote forward success for: listen 2255, connect localhost:2255
debug1: All remote forwarding requests processed
  • 1
    You can't diagnose everything from the client, you frequently need to check from the server (sometimes after increasing the verbosity to a sufficient debug level there as well) – HBruijn May 19 '17 at 13:51
  • Surely there exists some means to verify that packets are being forwarded or not. – Chris Stryczynski May 19 '17 at 14:09
2

When you specify 2255:localhost:2255 fills the missing hostname in front as a localhost. This will really bind only to localhost address (loopback). If you want to use it also "from outside", you need to use the server IP for the remote port forwarding, such as example.com:2255:localhost:2255.

| improve this answer | |
  • I'm not too sure where I imply that I'd like to access this "from outside"? – Chris Stryczynski May 19 '17 at 15:21
  • To localhost, you can connecton only from that machine (and not from any other). To the IP of that server, you can connect also from other machines in the network. – Jakuje May 19 '17 at 15:22
  • It is not clear what you mean by "not working" in the question, but this could be the case. – Jakuje May 19 '17 at 15:23
  • localhost is lo interface on example.com – Mikhail Khirgiy May 19 '17 at 15:31
  • @MikhailKhirgiy yes. And so what? – Jakuje May 19 '17 at 15:32
2

You need GatewayPorts yes in sshd_config to be able to access it from outside.

| improve this answer | |
1

If I were to diagnose this today I'd probably have a look at tcpdump:

tcpdump -v -i any tcp port 2255 -A.

| improve this answer | |
  • Why this? I try and see gibberish... – jaromrax Mar 13 '19 at 12:33
0

I'd do sudo netstat -a | grep 2255 and sshd -T It shows me now:

tcp        0      0 localhost:2255         *:*                     LISTEN 

So it still binds to localhost even I did ssh -R server_ip:2255:localhost2255 server_ip.

sshd -T | grep -i gatewayports shows gateway ports set to no, which might be the reason.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.