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

Thread: ssh: connect to host localhost port 22: Connection refused

  1. #1
    Join Date
    Jan 2012
    Beans
    3

    Smile ssh: connect to host localhost port 22: Connection refused

    Hello!

    I've been battling with this issue for 2 days and I've not been very successful, just yet. I'm simply unable to ssh to even my localhost.

    Here's what I've been trying out.
    1. Firewall issues: 1. Turned ff the firewall via the UI firewall manager as well as the CLI (IPTABLES commands here https://help.ubuntu.com/8.04/serverg.../firewall.html)

    2. checked, re-checked andupdated my openssh-server.
    o/p: apt-get install openssh-server
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    openssh-server is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

    3. Eve tried changing the port no from 22 . still, unable to connect.

    Problem:

    1. ~# /etc/init.d/sshd restart (OR start)
    bash: /etc/init.d/sshd: No such file or directory
    However, there's a file called ssh in the same path

    So, I tried starting it(SSH). Then did a pgrep SSH(gives the no) but pgrep SSHD returns nothing.

    My predictions: 1. SSH is not even installed? If so, what should I do now?

    PS- I'm a complete newbie to Ubuntu and I'm simply loving t already. I've learned SO much
    Thanks in advance!

  2. #2
    Join Date
    Apr 2009
    Location
    UK Lake District
    Beans
    3,092
    Distro
    Kubuntu 18.04 Bionic Beaver

    Re: ssh: connect to host localhost port 22: Connection refused

    How are you trying to connect?
    Using a terminal?
    or Nautilus > Connect to server?
    or other?
    Ubuntu 18.04

  3. #3
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,790
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: ssh: connect to host localhost port 22: Connection refused

    Could you post the result of these commands?
    Code:
    sudo service ssh restart
    
    ps aux | grep -i ssh
    Regards.

  4. #4
    Join Date
    Jan 2012
    Beans
    3

    Re: ssh: connect to host localhost port 22: Connection refused

    I'm using the terminal to connect ie ssh localhost

    Also,
    #sudo service ssh restart
    restart: Unknown instance:

    And
    ps aux | grep -i ssh
    root 1577 0.0 0.0 3348 200 ? Ss Jan21 0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session gnome-session
    hduser 13685 0.0 0.0 10932 3672 pts/8 T 10:20 0:00 vim /etc/init.d/sshd
    root 14154 0.0 0.0 4012 780 pts/11 S+ 10:56 0:00 grep --color=auto -i ssh

    In case this helps I was trying out commands on the CLI and i'd done this previously:
    $ sudo addgroup hadoop $ sudo adduser --ingroup hadoop hduser

  5. #5
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,790
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: ssh: connect to host localhost port 22: Connection refused

    Is looks like the service is down (restart cannot be performed).

    Try starting it:
    Code:
    sudo service ssh start
    Then check if it is running again:
    Code:
    ps aux | grep -i ssh
    You should see a process named '/usr/sbin/sshd' running. If so, try to connect again.

    Hope it helps.
    Regards.

  6. #6
    Join Date
    Jan 2012
    Beans
    3

    Re: ssh: connect to host localhost port 22: Connection refused

    Thanks for the help. However, I still seem to face the same issue:
    1. tried starting ssh. worked fine
    2. ps aux|grep -i ssh
    root 1577 0.0 0.0 3348 200 ? Ss Jan21 0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session gnome-session
    hduser 13685 0.0 0.0 10932 3672 pts/8 T 10:20 0:00 vim /etc/init.d/sshd
    root 14486 0.0 0.0 4012 780 pts/11 S+ 11:14 0:00 grep --color=auto -i ssh

    Help, please?

  7. #7
    Join Date
    Apr 2011
    Beans
    2

    Re: ssh: connect to host localhost port 22: Connection refused

    I was having a similar problem on my work computer, I found that removing and reinstalling OpenSSH fixed it for me. Not sure if it will work for you, but it's worth a shot.

    remove OpenSSH:
    Code:
    sudo apt-get remove openssh-client openssh-server
    install OpenSSH again:
    Code:
    sudo apt-get install openssh-client openssh-server
    Hope this helps!

  8. #8
    Join Date
    Mar 2010
    Beans
    1

    Re: ssh: connect to host localhost port 22: Connection refused

    Quote Originally Posted by Nethos View Post
    I was having a similar problem on my work computer, I found that removing and reinstalling OpenSSH fixed it for me. Not sure if it will work for you, but it's worth a shot.

    remove OpenSSH:
    Code:
    sudo apt-get remove openssh-client openssh-server
    install OpenSSH again:
    Code:
    sudo apt-get install openssh-client openssh-server
    Hope this helps!
    This fixed it for me! who would have guessed it was that simple eh? Thanks man!

  9. #9
    Join Date
    Mar 2009
    Beans
    2

    Re: ssh: connect to host localhost port 22: Connection refused

    Quote Originally Posted by xxclear View Post
    This fixed it for me! who would have guessed it was that simple eh? Thanks man!
    Thanks for me also...

  10. #10
    Join Date
    Oct 2012
    Beans
    1

    Re: ssh: connect to host localhost port 22: Connection refused

    This fixed it for me! who would have guessed it was that simple eh? Thanks man!
    And for me as well, Nethos Thank you very much !!

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
  •