Not able to ssh to another computer, but can ping it?

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











up vote
15
down vote

favorite
3












Unable to ssh to another computer but can ping it? Not sure what I am missing?

Using a Netgear router



bash-3.2$ ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether xx:xx:xx:xx:xx:xx
media: autoselect (none)
status: inactive
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether xx:xx:xx:xx:xx:xx
inet6 xxxx::xxxx:xxxx:xxxx:xxxxxx prefixlen 64 scopeid 0x5
inet 10.0.0.3 netmask 0xffffff00 broadcast 10.0.0.255
media: autoselect
status: active
fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078
lladdr xx:xx:xx:xx:xx:xx:xx:xx
media: autoselect <full-duplex>
status: inactive
bash-3.2$ ssh jeremy@10.0.0.4
ssh: connect to host 10.0.0.4 port 22: Connection refused
bash-3.2$ ssh -p 5900 jeremy@10.0.0.4
ssh: connect to host 10.0.0.4 port 5900: Connection refused
bash-3.2$ ping 10.0.0.3
PING 10.0.0.3 (10.0.0.3): 56 data bytes
64 bytes from 10.0.0.3: icmp_seq=0 ttl=64 time=0.046 ms
64 bytes from 10.0.0.3: icmp_seq=1 ttl=64 time=0.079 ms
64 bytes from 10.0.0.3: icmp_seq=2 ttl=64 time=0.078 ms
64 bytes from 10.0.0.3: icmp_seq=3 ttl=64 time=0.077 ms
64 bytes from 10.0.0.3: icmp_seq=4 ttl=64 time=0.079 ms
64 bytes from 10.0.0.3: icmp_seq=5 ttl=64 time=0.081 ms
64 bytes from 10.0.0.3: icmp_seq=6 ttl=64 time=0.078 ms
^C
--- 10.0.0.3 ping statistics ---
7 packets transmitted, 7 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.046/0.074/0.081/0.011 ms
bash-3.2$ ping 10.0.0.4
PING 10.0.0.4 (10.0.0.4): 56 data bytes
64 bytes from 10.0.0.4: icmp_seq=0 ttl=64 time=2.667 ms
64 bytes from 10.0.0.4: icmp_seq=1 ttl=64 time=2.675 ms
64 bytes from 10.0.0.4: icmp_seq=2 ttl=64 time=2.969 ms
64 bytes from 10.0.0.4: icmp_seq=3 ttl=64 time=2.663 ms
64 bytes from 10.0.0.4: icmp_seq=4 ttl=64 time=2.723 ms
^C
--- 10.0.0.4 ping statistics ---
5 packets transmitted, 5 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 2.663/2.739/2.969/0.117 ms
bash-3.2$









share|improve this question

























    up vote
    15
    down vote

    favorite
    3












    Unable to ssh to another computer but can ping it? Not sure what I am missing?

    Using a Netgear router



    bash-3.2$ ifconfig
    lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    inet6 ::1 prefixlen 128
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
    inet 127.0.0.1 netmask 0xff000000
    gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
    stf0: flags=0<> mtu 1280
    en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether xx:xx:xx:xx:xx:xx
    media: autoselect (none)
    status: inactive
    en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether xx:xx:xx:xx:xx:xx
    inet6 xxxx::xxxx:xxxx:xxxx:xxxxxx prefixlen 64 scopeid 0x5
    inet 10.0.0.3 netmask 0xffffff00 broadcast 10.0.0.255
    media: autoselect
    status: active
    fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078
    lladdr xx:xx:xx:xx:xx:xx:xx:xx
    media: autoselect <full-duplex>
    status: inactive
    bash-3.2$ ssh jeremy@10.0.0.4
    ssh: connect to host 10.0.0.4 port 22: Connection refused
    bash-3.2$ ssh -p 5900 jeremy@10.0.0.4
    ssh: connect to host 10.0.0.4 port 5900: Connection refused
    bash-3.2$ ping 10.0.0.3
    PING 10.0.0.3 (10.0.0.3): 56 data bytes
    64 bytes from 10.0.0.3: icmp_seq=0 ttl=64 time=0.046 ms
    64 bytes from 10.0.0.3: icmp_seq=1 ttl=64 time=0.079 ms
    64 bytes from 10.0.0.3: icmp_seq=2 ttl=64 time=0.078 ms
    64 bytes from 10.0.0.3: icmp_seq=3 ttl=64 time=0.077 ms
    64 bytes from 10.0.0.3: icmp_seq=4 ttl=64 time=0.079 ms
    64 bytes from 10.0.0.3: icmp_seq=5 ttl=64 time=0.081 ms
    64 bytes from 10.0.0.3: icmp_seq=6 ttl=64 time=0.078 ms
    ^C
    --- 10.0.0.3 ping statistics ---
    7 packets transmitted, 7 packets received, 0.0% packet loss
    round-trip min/avg/max/stddev = 0.046/0.074/0.081/0.011 ms
    bash-3.2$ ping 10.0.0.4
    PING 10.0.0.4 (10.0.0.4): 56 data bytes
    64 bytes from 10.0.0.4: icmp_seq=0 ttl=64 time=2.667 ms
    64 bytes from 10.0.0.4: icmp_seq=1 ttl=64 time=2.675 ms
    64 bytes from 10.0.0.4: icmp_seq=2 ttl=64 time=2.969 ms
    64 bytes from 10.0.0.4: icmp_seq=3 ttl=64 time=2.663 ms
    64 bytes from 10.0.0.4: icmp_seq=4 ttl=64 time=2.723 ms
    ^C
    --- 10.0.0.4 ping statistics ---
    5 packets transmitted, 5 packets received, 0.0% packet loss
    round-trip min/avg/max/stddev = 2.663/2.739/2.969/0.117 ms
    bash-3.2$









    share|improve this question























      up vote
      15
      down vote

      favorite
      3









      up vote
      15
      down vote

      favorite
      3






      3





      Unable to ssh to another computer but can ping it? Not sure what I am missing?

      Using a Netgear router



      bash-3.2$ ifconfig
      lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
      inet6 ::1 prefixlen 128
      inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
      inet 127.0.0.1 netmask 0xff000000
      gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
      stf0: flags=0<> mtu 1280
      en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
      ether xx:xx:xx:xx:xx:xx
      media: autoselect (none)
      status: inactive
      en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
      ether xx:xx:xx:xx:xx:xx
      inet6 xxxx::xxxx:xxxx:xxxx:xxxxxx prefixlen 64 scopeid 0x5
      inet 10.0.0.3 netmask 0xffffff00 broadcast 10.0.0.255
      media: autoselect
      status: active
      fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078
      lladdr xx:xx:xx:xx:xx:xx:xx:xx
      media: autoselect <full-duplex>
      status: inactive
      bash-3.2$ ssh jeremy@10.0.0.4
      ssh: connect to host 10.0.0.4 port 22: Connection refused
      bash-3.2$ ssh -p 5900 jeremy@10.0.0.4
      ssh: connect to host 10.0.0.4 port 5900: Connection refused
      bash-3.2$ ping 10.0.0.3
      PING 10.0.0.3 (10.0.0.3): 56 data bytes
      64 bytes from 10.0.0.3: icmp_seq=0 ttl=64 time=0.046 ms
      64 bytes from 10.0.0.3: icmp_seq=1 ttl=64 time=0.079 ms
      64 bytes from 10.0.0.3: icmp_seq=2 ttl=64 time=0.078 ms
      64 bytes from 10.0.0.3: icmp_seq=3 ttl=64 time=0.077 ms
      64 bytes from 10.0.0.3: icmp_seq=4 ttl=64 time=0.079 ms
      64 bytes from 10.0.0.3: icmp_seq=5 ttl=64 time=0.081 ms
      64 bytes from 10.0.0.3: icmp_seq=6 ttl=64 time=0.078 ms
      ^C
      --- 10.0.0.3 ping statistics ---
      7 packets transmitted, 7 packets received, 0.0% packet loss
      round-trip min/avg/max/stddev = 0.046/0.074/0.081/0.011 ms
      bash-3.2$ ping 10.0.0.4
      PING 10.0.0.4 (10.0.0.4): 56 data bytes
      64 bytes from 10.0.0.4: icmp_seq=0 ttl=64 time=2.667 ms
      64 bytes from 10.0.0.4: icmp_seq=1 ttl=64 time=2.675 ms
      64 bytes from 10.0.0.4: icmp_seq=2 ttl=64 time=2.969 ms
      64 bytes from 10.0.0.4: icmp_seq=3 ttl=64 time=2.663 ms
      64 bytes from 10.0.0.4: icmp_seq=4 ttl=64 time=2.723 ms
      ^C
      --- 10.0.0.4 ping statistics ---
      5 packets transmitted, 5 packets received, 0.0% packet loss
      round-trip min/avg/max/stddev = 2.663/2.739/2.969/0.117 ms
      bash-3.2$









      share|improve this question













      Unable to ssh to another computer but can ping it? Not sure what I am missing?

      Using a Netgear router



      bash-3.2$ ifconfig
      lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
      inet6 ::1 prefixlen 128
      inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
      inet 127.0.0.1 netmask 0xff000000
      gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
      stf0: flags=0<> mtu 1280
      en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
      ether xx:xx:xx:xx:xx:xx
      media: autoselect (none)
      status: inactive
      en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
      ether xx:xx:xx:xx:xx:xx
      inet6 xxxx::xxxx:xxxx:xxxx:xxxxxx prefixlen 64 scopeid 0x5
      inet 10.0.0.3 netmask 0xffffff00 broadcast 10.0.0.255
      media: autoselect
      status: active
      fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078
      lladdr xx:xx:xx:xx:xx:xx:xx:xx
      media: autoselect <full-duplex>
      status: inactive
      bash-3.2$ ssh jeremy@10.0.0.4
      ssh: connect to host 10.0.0.4 port 22: Connection refused
      bash-3.2$ ssh -p 5900 jeremy@10.0.0.4
      ssh: connect to host 10.0.0.4 port 5900: Connection refused
      bash-3.2$ ping 10.0.0.3
      PING 10.0.0.3 (10.0.0.3): 56 data bytes
      64 bytes from 10.0.0.3: icmp_seq=0 ttl=64 time=0.046 ms
      64 bytes from 10.0.0.3: icmp_seq=1 ttl=64 time=0.079 ms
      64 bytes from 10.0.0.3: icmp_seq=2 ttl=64 time=0.078 ms
      64 bytes from 10.0.0.3: icmp_seq=3 ttl=64 time=0.077 ms
      64 bytes from 10.0.0.3: icmp_seq=4 ttl=64 time=0.079 ms
      64 bytes from 10.0.0.3: icmp_seq=5 ttl=64 time=0.081 ms
      64 bytes from 10.0.0.3: icmp_seq=6 ttl=64 time=0.078 ms
      ^C
      --- 10.0.0.3 ping statistics ---
      7 packets transmitted, 7 packets received, 0.0% packet loss
      round-trip min/avg/max/stddev = 0.046/0.074/0.081/0.011 ms
      bash-3.2$ ping 10.0.0.4
      PING 10.0.0.4 (10.0.0.4): 56 data bytes
      64 bytes from 10.0.0.4: icmp_seq=0 ttl=64 time=2.667 ms
      64 bytes from 10.0.0.4: icmp_seq=1 ttl=64 time=2.675 ms
      64 bytes from 10.0.0.4: icmp_seq=2 ttl=64 time=2.969 ms
      64 bytes from 10.0.0.4: icmp_seq=3 ttl=64 time=2.663 ms
      64 bytes from 10.0.0.4: icmp_seq=4 ttl=64 time=2.723 ms
      ^C
      --- 10.0.0.4 ping statistics ---
      5 packets transmitted, 5 packets received, 0.0% packet loss
      round-trip min/avg/max/stddev = 2.663/2.739/2.969/0.117 ms
      bash-3.2$






      ssh






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 19 '13 at 0:34









      jdl

      2862410




      2862410




















          7 Answers
          7






          active

          oldest

          votes

















          up vote
          17
          down vote



          accepted










          The server is either not running sshd (and hence not listening on port 22) or has a firewall blocking port 22 (the default ssh port), or in incredibly rare cases running ssh on some other port (which is almost certainly not the case).



          First check to make sure sshd is installed (using debian examples)



          sudo apt-get install openssh-server


          And if so, is it running:



          ps -ef | grep sshd


          then check to see if it is listening to port 22



          sudo netstat -nlp | grep :22
          tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 946/sshd
          tcp6 0 0 :::22 :::* LISTEN 946/sshd


          then check your firewall rules (this varies significantly, so I'll show a debian/ubuntu/etc example):



          sudo ufw status

          sudo ufw show listening
          tcp:
          22 * (sshd)
          24224 * (ruby)
          tcp6:
          22 * (sshd)
          8080 * (java)
          udp:
          123 10.X.Y.Z (ntpd)
          123 * (ntpd)
          18649 * (dhclient)
          24224 * (ruby)
          34131 * (ruby)
          60001 10.87.43.24 (mosh-server)
          68 * (dhclient)
          udp6:
          123 fe80::1031:AAAA:BBBB:CCCC (ntpd)
          123 * (ntpd)
          48573 * (dhclient)


          If ufw shows it as closed then run (again a debian/ubuntu example)



          sudo ufw allow 22





          share|improve this answer






















          • FWIW, it's somewhat common to have external-facing machines run SSH on a different port to mitigate attack surface
            – s g
            Oct 18 '17 at 17:16

















          up vote
          3
          down vote













          Kind of a weird shot-in-the-dark, but make sure your IP didn't change. I had this issue once - I set a .bashrc alias alias sshdev='ssh me@123.2.3.4' as my typical way of logging in, and one day I started getting the following error:



          ME-M-216C:~ me$ sshdev 
          ssh: connect to host 123.2.3.4 port 22: Connection refused


          We just had a power outage at work which reset the IP's, so I was successfully pinging an IP but it wasn't the correct machine. You can use nslookup <IP> to make sure it's the correct machine name that you're trying to ssh into.






          share|improve this answer



























            up vote
            1
            down vote













            When you get the message "connection refused", that means that a daemon is not listening on that port or a firewall is rejecting the connection. To resolve the issue, ensure that ssh is running and the local firewall rules are not rejecting incoming connections on that port.






            share|improve this answer



























              up vote
              1
              down vote













              I had the same issue with Linux Lite. In order to fix the issue, I had to access Settings > Firewall Configuration. After signing into root, I changed the incoming setting to Allow and it worked.






              share|improve this answer



























                up vote
                0
                down vote













                Two thoughts.



                1. Does the firewall allow connections on port 22 to the machine?

                2. Is the ssh daemon (sshd) running?





                share|improve this answer



























                  up vote
                  0
                  down vote













                  this command worked for me. Try this.



                  update-rc.d -f ssh enable 2 3 4 5





                  share|improve this answer



























                    up vote
                    0
                    down vote













                    Steps followed in general:
                    1) ping to the destination host and verify and cross check IP address entered.
                    2) Check sudo service sshd status on both the hosts. If stopped, start the sshd service. If you get an error sshd.service not found, install openssh-server -> sudo apt install -y openssh-server and restart the sshd.service
                    3) Disabling the firewall or making changes to the config files should be considered the last option.






                    share|improve this answer








                    New contributor




                    Bharat247 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                    Check out our Code of Conduct.

















                      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%2f105800%2fnot-able-to-ssh-to-another-computer-but-can-ping-it%23new-answer', 'question_page');

                      );

                      Post as a guest






























                      7 Answers
                      7






                      active

                      oldest

                      votes








                      7 Answers
                      7






                      active

                      oldest

                      votes









                      active

                      oldest

                      votes






                      active

                      oldest

                      votes








                      up vote
                      17
                      down vote



                      accepted










                      The server is either not running sshd (and hence not listening on port 22) or has a firewall blocking port 22 (the default ssh port), or in incredibly rare cases running ssh on some other port (which is almost certainly not the case).



                      First check to make sure sshd is installed (using debian examples)



                      sudo apt-get install openssh-server


                      And if so, is it running:



                      ps -ef | grep sshd


                      then check to see if it is listening to port 22



                      sudo netstat -nlp | grep :22
                      tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 946/sshd
                      tcp6 0 0 :::22 :::* LISTEN 946/sshd


                      then check your firewall rules (this varies significantly, so I'll show a debian/ubuntu/etc example):



                      sudo ufw status

                      sudo ufw show listening
                      tcp:
                      22 * (sshd)
                      24224 * (ruby)
                      tcp6:
                      22 * (sshd)
                      8080 * (java)
                      udp:
                      123 10.X.Y.Z (ntpd)
                      123 * (ntpd)
                      18649 * (dhclient)
                      24224 * (ruby)
                      34131 * (ruby)
                      60001 10.87.43.24 (mosh-server)
                      68 * (dhclient)
                      udp6:
                      123 fe80::1031:AAAA:BBBB:CCCC (ntpd)
                      123 * (ntpd)
                      48573 * (dhclient)


                      If ufw shows it as closed then run (again a debian/ubuntu example)



                      sudo ufw allow 22





                      share|improve this answer






















                      • FWIW, it's somewhat common to have external-facing machines run SSH on a different port to mitigate attack surface
                        – s g
                        Oct 18 '17 at 17:16














                      up vote
                      17
                      down vote



                      accepted










                      The server is either not running sshd (and hence not listening on port 22) or has a firewall blocking port 22 (the default ssh port), or in incredibly rare cases running ssh on some other port (which is almost certainly not the case).



                      First check to make sure sshd is installed (using debian examples)



                      sudo apt-get install openssh-server


                      And if so, is it running:



                      ps -ef | grep sshd


                      then check to see if it is listening to port 22



                      sudo netstat -nlp | grep :22
                      tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 946/sshd
                      tcp6 0 0 :::22 :::* LISTEN 946/sshd


                      then check your firewall rules (this varies significantly, so I'll show a debian/ubuntu/etc example):



                      sudo ufw status

                      sudo ufw show listening
                      tcp:
                      22 * (sshd)
                      24224 * (ruby)
                      tcp6:
                      22 * (sshd)
                      8080 * (java)
                      udp:
                      123 10.X.Y.Z (ntpd)
                      123 * (ntpd)
                      18649 * (dhclient)
                      24224 * (ruby)
                      34131 * (ruby)
                      60001 10.87.43.24 (mosh-server)
                      68 * (dhclient)
                      udp6:
                      123 fe80::1031:AAAA:BBBB:CCCC (ntpd)
                      123 * (ntpd)
                      48573 * (dhclient)


                      If ufw shows it as closed then run (again a debian/ubuntu example)



                      sudo ufw allow 22





                      share|improve this answer






















                      • FWIW, it's somewhat common to have external-facing machines run SSH on a different port to mitigate attack surface
                        – s g
                        Oct 18 '17 at 17:16












                      up vote
                      17
                      down vote



                      accepted







                      up vote
                      17
                      down vote



                      accepted






                      The server is either not running sshd (and hence not listening on port 22) or has a firewall blocking port 22 (the default ssh port), or in incredibly rare cases running ssh on some other port (which is almost certainly not the case).



                      First check to make sure sshd is installed (using debian examples)



                      sudo apt-get install openssh-server


                      And if so, is it running:



                      ps -ef | grep sshd


                      then check to see if it is listening to port 22



                      sudo netstat -nlp | grep :22
                      tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 946/sshd
                      tcp6 0 0 :::22 :::* LISTEN 946/sshd


                      then check your firewall rules (this varies significantly, so I'll show a debian/ubuntu/etc example):



                      sudo ufw status

                      sudo ufw show listening
                      tcp:
                      22 * (sshd)
                      24224 * (ruby)
                      tcp6:
                      22 * (sshd)
                      8080 * (java)
                      udp:
                      123 10.X.Y.Z (ntpd)
                      123 * (ntpd)
                      18649 * (dhclient)
                      24224 * (ruby)
                      34131 * (ruby)
                      60001 10.87.43.24 (mosh-server)
                      68 * (dhclient)
                      udp6:
                      123 fe80::1031:AAAA:BBBB:CCCC (ntpd)
                      123 * (ntpd)
                      48573 * (dhclient)


                      If ufw shows it as closed then run (again a debian/ubuntu example)



                      sudo ufw allow 22





                      share|improve this answer














                      The server is either not running sshd (and hence not listening on port 22) or has a firewall blocking port 22 (the default ssh port), or in incredibly rare cases running ssh on some other port (which is almost certainly not the case).



                      First check to make sure sshd is installed (using debian examples)



                      sudo apt-get install openssh-server


                      And if so, is it running:



                      ps -ef | grep sshd


                      then check to see if it is listening to port 22



                      sudo netstat -nlp | grep :22
                      tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 946/sshd
                      tcp6 0 0 :::22 :::* LISTEN 946/sshd


                      then check your firewall rules (this varies significantly, so I'll show a debian/ubuntu/etc example):



                      sudo ufw status

                      sudo ufw show listening
                      tcp:
                      22 * (sshd)
                      24224 * (ruby)
                      tcp6:
                      22 * (sshd)
                      8080 * (java)
                      udp:
                      123 10.X.Y.Z (ntpd)
                      123 * (ntpd)
                      18649 * (dhclient)
                      24224 * (ruby)
                      34131 * (ruby)
                      60001 10.87.43.24 (mosh-server)
                      68 * (dhclient)
                      udp6:
                      123 fe80::1031:AAAA:BBBB:CCCC (ntpd)
                      123 * (ntpd)
                      48573 * (dhclient)


                      If ufw shows it as closed then run (again a debian/ubuntu example)



                      sudo ufw allow 22






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Dec 19 '13 at 1:19

























                      answered Dec 19 '13 at 0:38









                      Arthur Ulfeldt

                      877611




                      877611











                      • FWIW, it's somewhat common to have external-facing machines run SSH on a different port to mitigate attack surface
                        – s g
                        Oct 18 '17 at 17:16
















                      • FWIW, it's somewhat common to have external-facing machines run SSH on a different port to mitigate attack surface
                        – s g
                        Oct 18 '17 at 17:16















                      FWIW, it's somewhat common to have external-facing machines run SSH on a different port to mitigate attack surface
                      – s g
                      Oct 18 '17 at 17:16




                      FWIW, it's somewhat common to have external-facing machines run SSH on a different port to mitigate attack surface
                      – s g
                      Oct 18 '17 at 17:16












                      up vote
                      3
                      down vote













                      Kind of a weird shot-in-the-dark, but make sure your IP didn't change. I had this issue once - I set a .bashrc alias alias sshdev='ssh me@123.2.3.4' as my typical way of logging in, and one day I started getting the following error:



                      ME-M-216C:~ me$ sshdev 
                      ssh: connect to host 123.2.3.4 port 22: Connection refused


                      We just had a power outage at work which reset the IP's, so I was successfully pinging an IP but it wasn't the correct machine. You can use nslookup <IP> to make sure it's the correct machine name that you're trying to ssh into.






                      share|improve this answer
























                        up vote
                        3
                        down vote













                        Kind of a weird shot-in-the-dark, but make sure your IP didn't change. I had this issue once - I set a .bashrc alias alias sshdev='ssh me@123.2.3.4' as my typical way of logging in, and one day I started getting the following error:



                        ME-M-216C:~ me$ sshdev 
                        ssh: connect to host 123.2.3.4 port 22: Connection refused


                        We just had a power outage at work which reset the IP's, so I was successfully pinging an IP but it wasn't the correct machine. You can use nslookup <IP> to make sure it's the correct machine name that you're trying to ssh into.






                        share|improve this answer






















                          up vote
                          3
                          down vote










                          up vote
                          3
                          down vote









                          Kind of a weird shot-in-the-dark, but make sure your IP didn't change. I had this issue once - I set a .bashrc alias alias sshdev='ssh me@123.2.3.4' as my typical way of logging in, and one day I started getting the following error:



                          ME-M-216C:~ me$ sshdev 
                          ssh: connect to host 123.2.3.4 port 22: Connection refused


                          We just had a power outage at work which reset the IP's, so I was successfully pinging an IP but it wasn't the correct machine. You can use nslookup <IP> to make sure it's the correct machine name that you're trying to ssh into.






                          share|improve this answer












                          Kind of a weird shot-in-the-dark, but make sure your IP didn't change. I had this issue once - I set a .bashrc alias alias sshdev='ssh me@123.2.3.4' as my typical way of logging in, and one day I started getting the following error:



                          ME-M-216C:~ me$ sshdev 
                          ssh: connect to host 123.2.3.4 port 22: Connection refused


                          We just had a power outage at work which reset the IP's, so I was successfully pinging an IP but it wasn't the correct machine. You can use nslookup <IP> to make sure it's the correct machine name that you're trying to ssh into.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 20 '14 at 16:59









                          s g

                          240217




                          240217




















                              up vote
                              1
                              down vote













                              When you get the message "connection refused", that means that a daemon is not listening on that port or a firewall is rejecting the connection. To resolve the issue, ensure that ssh is running and the local firewall rules are not rejecting incoming connections on that port.






                              share|improve this answer
























                                up vote
                                1
                                down vote













                                When you get the message "connection refused", that means that a daemon is not listening on that port or a firewall is rejecting the connection. To resolve the issue, ensure that ssh is running and the local firewall rules are not rejecting incoming connections on that port.






                                share|improve this answer






















                                  up vote
                                  1
                                  down vote










                                  up vote
                                  1
                                  down vote









                                  When you get the message "connection refused", that means that a daemon is not listening on that port or a firewall is rejecting the connection. To resolve the issue, ensure that ssh is running and the local firewall rules are not rejecting incoming connections on that port.






                                  share|improve this answer












                                  When you get the message "connection refused", that means that a daemon is not listening on that port or a firewall is rejecting the connection. To resolve the issue, ensure that ssh is running and the local firewall rules are not rejecting incoming connections on that port.







                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Dec 19 '13 at 0:37









                                  jordanm

                                  29.4k27991




                                  29.4k27991




















                                      up vote
                                      1
                                      down vote













                                      I had the same issue with Linux Lite. In order to fix the issue, I had to access Settings > Firewall Configuration. After signing into root, I changed the incoming setting to Allow and it worked.






                                      share|improve this answer
























                                        up vote
                                        1
                                        down vote













                                        I had the same issue with Linux Lite. In order to fix the issue, I had to access Settings > Firewall Configuration. After signing into root, I changed the incoming setting to Allow and it worked.






                                        share|improve this answer






















                                          up vote
                                          1
                                          down vote










                                          up vote
                                          1
                                          down vote









                                          I had the same issue with Linux Lite. In order to fix the issue, I had to access Settings > Firewall Configuration. After signing into root, I changed the incoming setting to Allow and it worked.






                                          share|improve this answer












                                          I had the same issue with Linux Lite. In order to fix the issue, I had to access Settings > Firewall Configuration. After signing into root, I changed the incoming setting to Allow and it worked.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Jan 8 '17 at 0:09









                                          koziez

                                          111




                                          111




















                                              up vote
                                              0
                                              down vote













                                              Two thoughts.



                                              1. Does the firewall allow connections on port 22 to the machine?

                                              2. Is the ssh daemon (sshd) running?





                                              share|improve this answer
























                                                up vote
                                                0
                                                down vote













                                                Two thoughts.



                                                1. Does the firewall allow connections on port 22 to the machine?

                                                2. Is the ssh daemon (sshd) running?





                                                share|improve this answer






















                                                  up vote
                                                  0
                                                  down vote










                                                  up vote
                                                  0
                                                  down vote









                                                  Two thoughts.



                                                  1. Does the firewall allow connections on port 22 to the machine?

                                                  2. Is the ssh daemon (sshd) running?





                                                  share|improve this answer












                                                  Two thoughts.



                                                  1. Does the firewall allow connections on port 22 to the machine?

                                                  2. Is the ssh daemon (sshd) running?






                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered Dec 19 '13 at 0:37









                                                  kronenpj

                                                  27413




                                                  27413




















                                                      up vote
                                                      0
                                                      down vote













                                                      this command worked for me. Try this.



                                                      update-rc.d -f ssh enable 2 3 4 5





                                                      share|improve this answer
























                                                        up vote
                                                        0
                                                        down vote













                                                        this command worked for me. Try this.



                                                        update-rc.d -f ssh enable 2 3 4 5





                                                        share|improve this answer






















                                                          up vote
                                                          0
                                                          down vote










                                                          up vote
                                                          0
                                                          down vote









                                                          this command worked for me. Try this.



                                                          update-rc.d -f ssh enable 2 3 4 5





                                                          share|improve this answer












                                                          this command worked for me. Try this.



                                                          update-rc.d -f ssh enable 2 3 4 5






                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered Jun 19 at 11:40









                                                          Jacob Abraham

                                                          1012




                                                          1012




















                                                              up vote
                                                              0
                                                              down vote













                                                              Steps followed in general:
                                                              1) ping to the destination host and verify and cross check IP address entered.
                                                              2) Check sudo service sshd status on both the hosts. If stopped, start the sshd service. If you get an error sshd.service not found, install openssh-server -> sudo apt install -y openssh-server and restart the sshd.service
                                                              3) Disabling the firewall or making changes to the config files should be considered the last option.






                                                              share|improve this answer








                                                              New contributor




                                                              Bharat247 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                              Check out our Code of Conduct.





















                                                                up vote
                                                                0
                                                                down vote













                                                                Steps followed in general:
                                                                1) ping to the destination host and verify and cross check IP address entered.
                                                                2) Check sudo service sshd status on both the hosts. If stopped, start the sshd service. If you get an error sshd.service not found, install openssh-server -> sudo apt install -y openssh-server and restart the sshd.service
                                                                3) Disabling the firewall or making changes to the config files should be considered the last option.






                                                                share|improve this answer








                                                                New contributor




                                                                Bharat247 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                Check out our Code of Conduct.



















                                                                  up vote
                                                                  0
                                                                  down vote










                                                                  up vote
                                                                  0
                                                                  down vote









                                                                  Steps followed in general:
                                                                  1) ping to the destination host and verify and cross check IP address entered.
                                                                  2) Check sudo service sshd status on both the hosts. If stopped, start the sshd service. If you get an error sshd.service not found, install openssh-server -> sudo apt install -y openssh-server and restart the sshd.service
                                                                  3) Disabling the firewall or making changes to the config files should be considered the last option.






                                                                  share|improve this answer








                                                                  New contributor




                                                                  Bharat247 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                  Check out our Code of Conduct.









                                                                  Steps followed in general:
                                                                  1) ping to the destination host and verify and cross check IP address entered.
                                                                  2) Check sudo service sshd status on both the hosts. If stopped, start the sshd service. If you get an error sshd.service not found, install openssh-server -> sudo apt install -y openssh-server and restart the sshd.service
                                                                  3) Disabling the firewall or making changes to the config files should be considered the last option.







                                                                  share|improve this answer








                                                                  New contributor




                                                                  Bharat247 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                  Check out our Code of Conduct.









                                                                  share|improve this answer



                                                                  share|improve this answer






                                                                  New contributor




                                                                  Bharat247 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                  Check out our Code of Conduct.









                                                                  answered 22 mins ago









                                                                  Bharat247

                                                                  11




                                                                  11




                                                                  New contributor




                                                                  Bharat247 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                  Check out our Code of Conduct.





                                                                  New contributor





                                                                  Bharat247 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                  Check out our Code of Conduct.






                                                                  Bharat247 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                  Check out our Code of Conduct.



























                                                                       

                                                                      draft saved


                                                                      draft discarded















































                                                                       


                                                                      draft saved


                                                                      draft discarded














                                                                      StackExchange.ready(
                                                                      function ()
                                                                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f105800%2fnot-able-to-ssh-to-another-computer-but-can-ping-it%23new-answer', 'question_page');

                                                                      );

                                                                      Post as a guest













































































                                                                      Popular posts from this blog

                                                                      Peggy Mitchell

                                                                      Palaiologos

                                                                      The Forum (Inglewood, California)