“port : connection refused” when trying to SSH over tunnel












0















I have three machines (let's call them A, B, and C). I want to SSH from A via B into C.



I set up an SSH tunnel from B to C:



B:~ $ ssh user@C -NL 2222:localhost:22


I know the tunnel is working, because on machine B, localhost:2222 leads to C:



B:~ $ ssh -p 2222 localhost
user@localhost's password:
Linux C 4.19.0-1-amd64 #1 SMP Debian 4.19.12-1 (2018-12-22) x86_64
...
C:~ $


But when I try to do the same from machine A, I get a connection refused error:



A:~ $ ssh -vvvvp 2222 B
OpenSSH_7.9p1 Debian-5, OpenSSL 1.1.1a 20 Nov 2018
debug1: Reading configuration data /home/user/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolve_canonicalize: hostname B is address
debug2: ssh_connect_direct
debug1: Connectiong to B [B] port 2222.
debug1: connect to address B port 2222: connection refused
ssh: connect to host B port 2222: connection refused


What am I missing?





What I've checked/tried





  • Firewall: There is, indeed, a firewall on B. However, I can SSH into it sans tunnel just fine, and the rules for port 22 and port 2222 are identical:


B:~ $ sudo ufw status
[sudo] password for user:
Status: active

To Action From
-- ------ ----
22/tcp ALLOW Anywhere
2222/tcp ALLOW Anywhere
22/tcp (v6) ALLOW Anywhere (v6)
2222/tcp (v6) ALLOW Anywhere (v6)




  • Port forwarding: This is all happening over the local network, though the goal is to do it remotely. B is exposed to the public Internet via my home router / port forwarding, and rules for 22 and 2222 are, again, identical.









share



























    0















    I have three machines (let's call them A, B, and C). I want to SSH from A via B into C.



    I set up an SSH tunnel from B to C:



    B:~ $ ssh user@C -NL 2222:localhost:22


    I know the tunnel is working, because on machine B, localhost:2222 leads to C:



    B:~ $ ssh -p 2222 localhost
    user@localhost's password:
    Linux C 4.19.0-1-amd64 #1 SMP Debian 4.19.12-1 (2018-12-22) x86_64
    ...
    C:~ $


    But when I try to do the same from machine A, I get a connection refused error:



    A:~ $ ssh -vvvvp 2222 B
    OpenSSH_7.9p1 Debian-5, OpenSSL 1.1.1a 20 Nov 2018
    debug1: Reading configuration data /home/user/.ssh/config
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 19: Applying options for *
    debug2: resolve_canonicalize: hostname B is address
    debug2: ssh_connect_direct
    debug1: Connectiong to B [B] port 2222.
    debug1: connect to address B port 2222: connection refused
    ssh: connect to host B port 2222: connection refused


    What am I missing?





    What I've checked/tried





    • Firewall: There is, indeed, a firewall on B. However, I can SSH into it sans tunnel just fine, and the rules for port 22 and port 2222 are identical:


    B:~ $ sudo ufw status
    [sudo] password for user:
    Status: active

    To Action From
    -- ------ ----
    22/tcp ALLOW Anywhere
    2222/tcp ALLOW Anywhere
    22/tcp (v6) ALLOW Anywhere (v6)
    2222/tcp (v6) ALLOW Anywhere (v6)




    • Port forwarding: This is all happening over the local network, though the goal is to do it remotely. B is exposed to the public Internet via my home router / port forwarding, and rules for 22 and 2222 are, again, identical.









    share

























      0












      0








      0








      I have three machines (let's call them A, B, and C). I want to SSH from A via B into C.



      I set up an SSH tunnel from B to C:



      B:~ $ ssh user@C -NL 2222:localhost:22


      I know the tunnel is working, because on machine B, localhost:2222 leads to C:



      B:~ $ ssh -p 2222 localhost
      user@localhost's password:
      Linux C 4.19.0-1-amd64 #1 SMP Debian 4.19.12-1 (2018-12-22) x86_64
      ...
      C:~ $


      But when I try to do the same from machine A, I get a connection refused error:



      A:~ $ ssh -vvvvp 2222 B
      OpenSSH_7.9p1 Debian-5, OpenSSL 1.1.1a 20 Nov 2018
      debug1: Reading configuration data /home/user/.ssh/config
      debug1: Reading configuration data /etc/ssh/ssh_config
      debug1: /etc/ssh/ssh_config line 19: Applying options for *
      debug2: resolve_canonicalize: hostname B is address
      debug2: ssh_connect_direct
      debug1: Connectiong to B [B] port 2222.
      debug1: connect to address B port 2222: connection refused
      ssh: connect to host B port 2222: connection refused


      What am I missing?





      What I've checked/tried





      • Firewall: There is, indeed, a firewall on B. However, I can SSH into it sans tunnel just fine, and the rules for port 22 and port 2222 are identical:


      B:~ $ sudo ufw status
      [sudo] password for user:
      Status: active

      To Action From
      -- ------ ----
      22/tcp ALLOW Anywhere
      2222/tcp ALLOW Anywhere
      22/tcp (v6) ALLOW Anywhere (v6)
      2222/tcp (v6) ALLOW Anywhere (v6)




      • Port forwarding: This is all happening over the local network, though the goal is to do it remotely. B is exposed to the public Internet via my home router / port forwarding, and rules for 22 and 2222 are, again, identical.









      share














      I have three machines (let's call them A, B, and C). I want to SSH from A via B into C.



      I set up an SSH tunnel from B to C:



      B:~ $ ssh user@C -NL 2222:localhost:22


      I know the tunnel is working, because on machine B, localhost:2222 leads to C:



      B:~ $ ssh -p 2222 localhost
      user@localhost's password:
      Linux C 4.19.0-1-amd64 #1 SMP Debian 4.19.12-1 (2018-12-22) x86_64
      ...
      C:~ $


      But when I try to do the same from machine A, I get a connection refused error:



      A:~ $ ssh -vvvvp 2222 B
      OpenSSH_7.9p1 Debian-5, OpenSSL 1.1.1a 20 Nov 2018
      debug1: Reading configuration data /home/user/.ssh/config
      debug1: Reading configuration data /etc/ssh/ssh_config
      debug1: /etc/ssh/ssh_config line 19: Applying options for *
      debug2: resolve_canonicalize: hostname B is address
      debug2: ssh_connect_direct
      debug1: Connectiong to B [B] port 2222.
      debug1: connect to address B port 2222: connection refused
      ssh: connect to host B port 2222: connection refused


      What am I missing?





      What I've checked/tried





      • Firewall: There is, indeed, a firewall on B. However, I can SSH into it sans tunnel just fine, and the rules for port 22 and port 2222 are identical:


      B:~ $ sudo ufw status
      [sudo] password for user:
      Status: active

      To Action From
      -- ------ ----
      22/tcp ALLOW Anywhere
      2222/tcp ALLOW Anywhere
      22/tcp (v6) ALLOW Anywhere (v6)
      2222/tcp (v6) ALLOW Anywhere (v6)




      • Port forwarding: This is all happening over the local network, though the goal is to do it remotely. B is exposed to the public Internet via my home router / port forwarding, and rules for 22 and 2222 are, again, identical.







      ssh-tunneling





      share












      share










      share



      share










      asked 1 min ago









      Ryan LueRyan Lue

      22919




      22919






















          0






          active

          oldest

          votes











          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          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%2f497124%2fport-xxx-connection-refused-when-trying-to-ssh-over-tunnel%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f497124%2fport-xxx-connection-refused-when-trying-to-ssh-over-tunnel%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Accessing regular linux commands in Huawei's Dopra Linux

          Can't connect RFCOMM socket: Host is down

          Kernel panic - not syncing: Fatal Exception in Interrupt