ssh dynamic port forwarding with remote (-g) is not working

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I would like to allow a few client devices in my home network to connect to the internet, but the connection should go via my iMac which has an SSH tunnel to a remote server. I want to ultimately use the internet connection of the remote server to make requests on behalf of the client devices.



From the iMac I start the tunnel using



ssh -D 8127 -f -g -N -C -vvv myuser@remote_server


I configure the browser on the iMac with a proxy localhost:8127 and everything works fine. The web server I connect to sees an incoming connection from remote_server. So far so good.



But when I configure the same proxy settings in my clients, I get nothing back. The browser on my windows laptop comes back with 'The connection was reset'. I tried with an Android device and an iPad. None of them work.



The verbose logs from the tunnel don't reveal much.



debug1: Connection to port 8127 forwarding to socks port 0 requested.
debug2: fd 12 setting TCP_NODELAY
debug3: fd 12 is O_NONBLOCK
debug3: fd 12 is O_NONBLOCK
debug1: channel 5: new [dynamic-tcpip]
debug2: channel 5: pre_dynamic: have 0
debug2: channel 5: pre_dynamic: have 411
debug2: channel 5: zombie
debug2: channel 5: garbage collecting
debug1: channel 5: free: dynamic-tcpip, nchannels 7
debug3: channel 5: status: The following connections are open:
#2 direct-tcpip: listening port 8127 for 188.65.124.58 port 443, connect from 127.0.0.1 port 61067 to 127.0.0.1 port 8127 (t4 r0 i0/0 o0/0 fd 9/9 cc -1)
#3 direct-tcpip: listening port 8127 for 172.217.22.206 port 443, connect from 127.0.0.1 port 61091 to 127.0.0.1 port 8127 (t4 r1 i0/0 o0/0 fd 10/10 cc -1)
#4 direct-tcpip: listening port 8127 for 66.102.1.189 port 443, connect from 127.0.0.1 port 60990 to 127.0.0.1 port 8127 (t4 r2 i0/0 o0/0 fd 11/11 cc -1)
#6 direct-tcpip: listening port 8127 for 172.217.22.206 port 443, connect from 127.0.0.1 port 61092 to 127.0.0.1 port 8127 (t4 r4 i0/0 o0/0 fd 13/13 cc -1)


Does anyone have any idea why this is not working?







share|improve this question

























    up vote
    1
    down vote

    favorite












    I would like to allow a few client devices in my home network to connect to the internet, but the connection should go via my iMac which has an SSH tunnel to a remote server. I want to ultimately use the internet connection of the remote server to make requests on behalf of the client devices.



    From the iMac I start the tunnel using



    ssh -D 8127 -f -g -N -C -vvv myuser@remote_server


    I configure the browser on the iMac with a proxy localhost:8127 and everything works fine. The web server I connect to sees an incoming connection from remote_server. So far so good.



    But when I configure the same proxy settings in my clients, I get nothing back. The browser on my windows laptop comes back with 'The connection was reset'. I tried with an Android device and an iPad. None of them work.



    The verbose logs from the tunnel don't reveal much.



    debug1: Connection to port 8127 forwarding to socks port 0 requested.
    debug2: fd 12 setting TCP_NODELAY
    debug3: fd 12 is O_NONBLOCK
    debug3: fd 12 is O_NONBLOCK
    debug1: channel 5: new [dynamic-tcpip]
    debug2: channel 5: pre_dynamic: have 0
    debug2: channel 5: pre_dynamic: have 411
    debug2: channel 5: zombie
    debug2: channel 5: garbage collecting
    debug1: channel 5: free: dynamic-tcpip, nchannels 7
    debug3: channel 5: status: The following connections are open:
    #2 direct-tcpip: listening port 8127 for 188.65.124.58 port 443, connect from 127.0.0.1 port 61067 to 127.0.0.1 port 8127 (t4 r0 i0/0 o0/0 fd 9/9 cc -1)
    #3 direct-tcpip: listening port 8127 for 172.217.22.206 port 443, connect from 127.0.0.1 port 61091 to 127.0.0.1 port 8127 (t4 r1 i0/0 o0/0 fd 10/10 cc -1)
    #4 direct-tcpip: listening port 8127 for 66.102.1.189 port 443, connect from 127.0.0.1 port 60990 to 127.0.0.1 port 8127 (t4 r2 i0/0 o0/0 fd 11/11 cc -1)
    #6 direct-tcpip: listening port 8127 for 172.217.22.206 port 443, connect from 127.0.0.1 port 61092 to 127.0.0.1 port 8127 (t4 r4 i0/0 o0/0 fd 13/13 cc -1)


    Does anyone have any idea why this is not working?







    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I would like to allow a few client devices in my home network to connect to the internet, but the connection should go via my iMac which has an SSH tunnel to a remote server. I want to ultimately use the internet connection of the remote server to make requests on behalf of the client devices.



      From the iMac I start the tunnel using



      ssh -D 8127 -f -g -N -C -vvv myuser@remote_server


      I configure the browser on the iMac with a proxy localhost:8127 and everything works fine. The web server I connect to sees an incoming connection from remote_server. So far so good.



      But when I configure the same proxy settings in my clients, I get nothing back. The browser on my windows laptop comes back with 'The connection was reset'. I tried with an Android device and an iPad. None of them work.



      The verbose logs from the tunnel don't reveal much.



      debug1: Connection to port 8127 forwarding to socks port 0 requested.
      debug2: fd 12 setting TCP_NODELAY
      debug3: fd 12 is O_NONBLOCK
      debug3: fd 12 is O_NONBLOCK
      debug1: channel 5: new [dynamic-tcpip]
      debug2: channel 5: pre_dynamic: have 0
      debug2: channel 5: pre_dynamic: have 411
      debug2: channel 5: zombie
      debug2: channel 5: garbage collecting
      debug1: channel 5: free: dynamic-tcpip, nchannels 7
      debug3: channel 5: status: The following connections are open:
      #2 direct-tcpip: listening port 8127 for 188.65.124.58 port 443, connect from 127.0.0.1 port 61067 to 127.0.0.1 port 8127 (t4 r0 i0/0 o0/0 fd 9/9 cc -1)
      #3 direct-tcpip: listening port 8127 for 172.217.22.206 port 443, connect from 127.0.0.1 port 61091 to 127.0.0.1 port 8127 (t4 r1 i0/0 o0/0 fd 10/10 cc -1)
      #4 direct-tcpip: listening port 8127 for 66.102.1.189 port 443, connect from 127.0.0.1 port 60990 to 127.0.0.1 port 8127 (t4 r2 i0/0 o0/0 fd 11/11 cc -1)
      #6 direct-tcpip: listening port 8127 for 172.217.22.206 port 443, connect from 127.0.0.1 port 61092 to 127.0.0.1 port 8127 (t4 r4 i0/0 o0/0 fd 13/13 cc -1)


      Does anyone have any idea why this is not working?







      share|improve this question













      I would like to allow a few client devices in my home network to connect to the internet, but the connection should go via my iMac which has an SSH tunnel to a remote server. I want to ultimately use the internet connection of the remote server to make requests on behalf of the client devices.



      From the iMac I start the tunnel using



      ssh -D 8127 -f -g -N -C -vvv myuser@remote_server


      I configure the browser on the iMac with a proxy localhost:8127 and everything works fine. The web server I connect to sees an incoming connection from remote_server. So far so good.



      But when I configure the same proxy settings in my clients, I get nothing back. The browser on my windows laptop comes back with 'The connection was reset'. I tried with an Android device and an iPad. None of them work.



      The verbose logs from the tunnel don't reveal much.



      debug1: Connection to port 8127 forwarding to socks port 0 requested.
      debug2: fd 12 setting TCP_NODELAY
      debug3: fd 12 is O_NONBLOCK
      debug3: fd 12 is O_NONBLOCK
      debug1: channel 5: new [dynamic-tcpip]
      debug2: channel 5: pre_dynamic: have 0
      debug2: channel 5: pre_dynamic: have 411
      debug2: channel 5: zombie
      debug2: channel 5: garbage collecting
      debug1: channel 5: free: dynamic-tcpip, nchannels 7
      debug3: channel 5: status: The following connections are open:
      #2 direct-tcpip: listening port 8127 for 188.65.124.58 port 443, connect from 127.0.0.1 port 61067 to 127.0.0.1 port 8127 (t4 r0 i0/0 o0/0 fd 9/9 cc -1)
      #3 direct-tcpip: listening port 8127 for 172.217.22.206 port 443, connect from 127.0.0.1 port 61091 to 127.0.0.1 port 8127 (t4 r1 i0/0 o0/0 fd 10/10 cc -1)
      #4 direct-tcpip: listening port 8127 for 66.102.1.189 port 443, connect from 127.0.0.1 port 60990 to 127.0.0.1 port 8127 (t4 r2 i0/0 o0/0 fd 11/11 cc -1)
      #6 direct-tcpip: listening port 8127 for 172.217.22.206 port 443, connect from 127.0.0.1 port 61092 to 127.0.0.1 port 8127 (t4 r4 i0/0 o0/0 fd 13/13 cc -1)


      Does anyone have any idea why this is not working?









      share|improve this question












      share|improve this question




      share|improve this question








      edited May 18 at 12:58









      roaima

      39.3k544105




      39.3k544105









      asked May 18 at 12:51









      sbarlow

      82




      82




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          You have bound only to a localhost port. It's not particularly clear in the documentation (see man ssh) from this segment:




          By default, the local port is bound in accordance with the GatewayPorts setting. However, an explicit bind_address may be used to bind the connection to a specific address. The bind_address of localhost indicates that the listening port be bound for local use only, while an empty address or * indicates that the port should be available from all interfaces.




          And from ssh_config:




          GatewayPorts Specifies whether remote hosts are allowed to connect to local forwarded ports. By default, ssh(1) binds local port forwardings to the loopback address. This prevents other remote hosts from connecting to forwarded ports. GatewayPorts can be used to specify that ssh should bind local port forwardings to the wildcard address, thus allowing remote hosts to connect to forwarded ports. The argument must be “yes” or “no”. The default is “no”.




          What this means is that when you use ssh -D 8127 you are using a port bound in accordance with GatewayPorts, which defaults to localhost, i.e. remote hosts cannot connect.



          If you specify ssh -D :8127 then you are including reference to an address , and since that address is empty it defaults to *, i.e. remote hosts can connect.



          Change your command to this, and it will work as you desire:



          ssh -D :8127 -f -g -N -C -vvv myuser@remote_server





          share|improve this answer





















          • Thanks roaima. Your advice was spot on. Works now. I had to put the socks proxy config into a .pac to get it working on some of the client devices. Thank you very much!
            – sbarlow
            May 18 at 14:56










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f444590%2fssh-dynamic-port-forwarding-with-remote-g-is-not-working%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote



          accepted










          You have bound only to a localhost port. It's not particularly clear in the documentation (see man ssh) from this segment:




          By default, the local port is bound in accordance with the GatewayPorts setting. However, an explicit bind_address may be used to bind the connection to a specific address. The bind_address of localhost indicates that the listening port be bound for local use only, while an empty address or * indicates that the port should be available from all interfaces.




          And from ssh_config:




          GatewayPorts Specifies whether remote hosts are allowed to connect to local forwarded ports. By default, ssh(1) binds local port forwardings to the loopback address. This prevents other remote hosts from connecting to forwarded ports. GatewayPorts can be used to specify that ssh should bind local port forwardings to the wildcard address, thus allowing remote hosts to connect to forwarded ports. The argument must be “yes” or “no”. The default is “no”.




          What this means is that when you use ssh -D 8127 you are using a port bound in accordance with GatewayPorts, which defaults to localhost, i.e. remote hosts cannot connect.



          If you specify ssh -D :8127 then you are including reference to an address , and since that address is empty it defaults to *, i.e. remote hosts can connect.



          Change your command to this, and it will work as you desire:



          ssh -D :8127 -f -g -N -C -vvv myuser@remote_server





          share|improve this answer





















          • Thanks roaima. Your advice was spot on. Works now. I had to put the socks proxy config into a .pac to get it working on some of the client devices. Thank you very much!
            – sbarlow
            May 18 at 14:56














          up vote
          0
          down vote



          accepted










          You have bound only to a localhost port. It's not particularly clear in the documentation (see man ssh) from this segment:




          By default, the local port is bound in accordance with the GatewayPorts setting. However, an explicit bind_address may be used to bind the connection to a specific address. The bind_address of localhost indicates that the listening port be bound for local use only, while an empty address or * indicates that the port should be available from all interfaces.




          And from ssh_config:




          GatewayPorts Specifies whether remote hosts are allowed to connect to local forwarded ports. By default, ssh(1) binds local port forwardings to the loopback address. This prevents other remote hosts from connecting to forwarded ports. GatewayPorts can be used to specify that ssh should bind local port forwardings to the wildcard address, thus allowing remote hosts to connect to forwarded ports. The argument must be “yes” or “no”. The default is “no”.




          What this means is that when you use ssh -D 8127 you are using a port bound in accordance with GatewayPorts, which defaults to localhost, i.e. remote hosts cannot connect.



          If you specify ssh -D :8127 then you are including reference to an address , and since that address is empty it defaults to *, i.e. remote hosts can connect.



          Change your command to this, and it will work as you desire:



          ssh -D :8127 -f -g -N -C -vvv myuser@remote_server





          share|improve this answer





















          • Thanks roaima. Your advice was spot on. Works now. I had to put the socks proxy config into a .pac to get it working on some of the client devices. Thank you very much!
            – sbarlow
            May 18 at 14:56












          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          You have bound only to a localhost port. It's not particularly clear in the documentation (see man ssh) from this segment:




          By default, the local port is bound in accordance with the GatewayPorts setting. However, an explicit bind_address may be used to bind the connection to a specific address. The bind_address of localhost indicates that the listening port be bound for local use only, while an empty address or * indicates that the port should be available from all interfaces.




          And from ssh_config:




          GatewayPorts Specifies whether remote hosts are allowed to connect to local forwarded ports. By default, ssh(1) binds local port forwardings to the loopback address. This prevents other remote hosts from connecting to forwarded ports. GatewayPorts can be used to specify that ssh should bind local port forwardings to the wildcard address, thus allowing remote hosts to connect to forwarded ports. The argument must be “yes” or “no”. The default is “no”.




          What this means is that when you use ssh -D 8127 you are using a port bound in accordance with GatewayPorts, which defaults to localhost, i.e. remote hosts cannot connect.



          If you specify ssh -D :8127 then you are including reference to an address , and since that address is empty it defaults to *, i.e. remote hosts can connect.



          Change your command to this, and it will work as you desire:



          ssh -D :8127 -f -g -N -C -vvv myuser@remote_server





          share|improve this answer













          You have bound only to a localhost port. It's not particularly clear in the documentation (see man ssh) from this segment:




          By default, the local port is bound in accordance with the GatewayPorts setting. However, an explicit bind_address may be used to bind the connection to a specific address. The bind_address of localhost indicates that the listening port be bound for local use only, while an empty address or * indicates that the port should be available from all interfaces.




          And from ssh_config:




          GatewayPorts Specifies whether remote hosts are allowed to connect to local forwarded ports. By default, ssh(1) binds local port forwardings to the loopback address. This prevents other remote hosts from connecting to forwarded ports. GatewayPorts can be used to specify that ssh should bind local port forwardings to the wildcard address, thus allowing remote hosts to connect to forwarded ports. The argument must be “yes” or “no”. The default is “no”.




          What this means is that when you use ssh -D 8127 you are using a port bound in accordance with GatewayPorts, which defaults to localhost, i.e. remote hosts cannot connect.



          If you specify ssh -D :8127 then you are including reference to an address , and since that address is empty it defaults to *, i.e. remote hosts can connect.



          Change your command to this, and it will work as you desire:



          ssh -D :8127 -f -g -N -C -vvv myuser@remote_server






          share|improve this answer













          share|improve this answer



          share|improve this answer











          answered May 18 at 13:04









          roaima

          39.3k544105




          39.3k544105











          • Thanks roaima. Your advice was spot on. Works now. I had to put the socks proxy config into a .pac to get it working on some of the client devices. Thank you very much!
            – sbarlow
            May 18 at 14:56
















          • Thanks roaima. Your advice was spot on. Works now. I had to put the socks proxy config into a .pac to get it working on some of the client devices. Thank you very much!
            – sbarlow
            May 18 at 14:56















          Thanks roaima. Your advice was spot on. Works now. I had to put the socks proxy config into a .pac to get it working on some of the client devices. Thank you very much!
          – sbarlow
          May 18 at 14:56




          Thanks roaima. Your advice was spot on. Works now. I had to put the socks proxy config into a .pac to get it working on some of the client devices. Thank you very much!
          – sbarlow
          May 18 at 14:56












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f444590%2fssh-dynamic-port-forwarding-with-remote-g-is-not-working%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?