Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: ssh is running but port 22 not open

  1. #1
    Join Date
    Dec 2009
    Beans
    36

    ssh is running but port 22 not open

    I have two computers on a LAN. (This is history not a Bazaar question, although I have one of those too) One of them (Ubuntu 9.04) I’m using as a Bazaar repository over sftp. It’s been working fine for about a year. Then we had a thunderstorm that knocked out our Internet service for a couple of days. When it came back up everything is working fine accept I could no longer “commit” to the server. A little detective work showed that ssh was not running on the server. I started it and Bazaar then couldn’t find the repository files. I still suspected an ssh problem, but port scans from both computers showed port 22 open on the server and I could do a ssh login from the client ok. Then I started fiddling with ssh on the server and now I have ssh problems on top of the Bazaar problems.

    On the server I deleted then regenerated the ssh keys. I’ve done
    sudo /etc/init.d/ssh reload
    sudo /etc/init.d/ssh start

    I get a normal starting message and
    ps –ef |grep ssh

    shows /usr/sbin/sshd running. But the port scan does not show 22 open and I get “connection refused” at the client.

    I’ve combed through all the forums I could find on Google and tried all of the suggestions. But, alas, I don’t find a solution anywhere.

    Ideas?

  2. #2
    Join Date
    May 2007
    Location
    New York, USA
    Beans
    278
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: ssh is running but port 22 not open

    A few things that might push you in the right direction:


    Is sshd listening? On the right port?

    Code:
    [jdeprizi@pioneer ~]$ sudo lsof -i | grep ssh
    [sudo] password for jdeprizi: 
    sshd      1170     root    3u  IPv4  11962      0t0  TCP *:ssh (LISTEN)
    sshd      1170     root    4u  IPv6  11966      0t0  TCP *:ssh (LISTEN)
    Code:
    [jdeprizi@pioneer ~]$ netstat -l --numeric-ports | grep 22
    tcp        0      0 *:22                        *:*                         LISTEN      
    tcp        0      0 *:22                        *:*                         LISTEN

    Is the firewall running? Check if it is blocking port 22.

    Code:
    sudo /etc/init.d/iptables status

  3. #3
    Join Date
    Dec 2009
    Beans
    36

    Re: ssh is running but port 22 not open

    Thanks for the quick reply. Yes to first two questions, sshd is listening on port 22. But for
    sudo /etc/init.d/iptables
    I get "command not found".

    Since posting I've noticed that may be the wrong forum. I'm not running the Ubuntu Server Edition.

  4. #4
    Join Date
    May 2007
    Location
    New York, USA
    Beans
    278
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: ssh is running but port 22 not open

    Does "ssh localhost" work on the machine running sshd?

  5. #5
    Join Date
    Dec 2009
    Beans
    36

    Re: ssh is running but port 22 not open

    Yep, ssh localhost on the server running sshd seems to work fine. But still no open port 22 is scanned from client or server either one.

  6. #6
    Join Date
    May 2007
    Location
    New York, USA
    Beans
    278
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: ssh is running but port 22 not open

    You're sure there's no firewall between the machines?

    I gave you a bad command before (gave you the Fedora version). Can you try:

    Code:
    sudo iptables --list

  7. #7
    Join Date
    Dec 2009
    Beans
    36

    Re: ssh is running but port 22 not open

    OK, iptables --list
    <code>
    ...:/etc/ssh$ sudo iptables --list
    Chain INPUT (policy ACCEPT)
    target prot opt source destination

    Chain FORWARD (policy ACCEPT)
    target prot opt source destination

    Chain OUTPUT (policy ACCEPT)
    target prot opt source destination
    </code>

    I'm not sure what this means but I would guess it is ok. Also, from the client scan port 80 is open and I can get web pages from the Apache http server. Don't know if that helps.

  8. #8
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: ssh is running but port 22 not open

    Firewall looks good.

    If you are using keys, see if you can boot off a livecd on another machine and then access the other machine via ssh.

    If that doesn't work, do you have denyhosts or something installed?
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  9. #9
    Join Date
    Dec 2009
    Beans
    36

    Re: ssh is running but port 22 not open

    If by "using keys" you mean ssh does not require a password, no.
    I have ssh server running on another machine on the LAN. From the problem machine I can see port 22 with a scan and I can do a ssh login. But from the other machine I can't see port 22 or do ssh login on the problem machine.

    Not running anything like "denyhosts" that I know of. As I mentioned, all was working before the power outage.

    I'm thinking of doing and apt-get purge and then reinstall ssh? Does that sound reasonable at this point?

  10. #10
    Join Date
    Dec 2009
    Beans
    36

    Re: ssh is running but port 22 not open

    Let's call the two machines G for good and P for problem. This morning the first thing I did was turn off all machines on my LAN, the hub and the router. I then rebooted everything in the reverse sequence - cable modem, router, hub, and then the computers.

    Then I reinstalled ssh on both machines G and P.

    sudo apt-get purge openssh-server openssh-client
    sudo apt-get install openssh-server openssh-client


    sshd in now running and port 22 shows on both machines. However -


    from P

    ssh G (check)
    ls (check – shows home directory of G)


    from G

    ssh P (check)
    ls (HERE IS THE PROBLEM – shows the home directory of G not P)


    The only good news here is that it answers my original Bazaar “file not found” problem. It is obviously an ssh problem. But I am baffled and out of ideas.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •