Ping works , but unable to do ssh

62,152

Solution 1

Removing and reinstalling ssh on the server worked for me :

My master node is : 192.168.1.6

My client is: 192.168.1.4

On the master I did this:

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

Now from my client I did this:

root@ubuntu:/home# ssh 192.168.1.6
[email protected]'s password: 
Welcome to Ubuntu 12.04.3 LTS (GNU/Linux 3.8.0-29-generic i686)

 * Documentation:  https://help.ubuntu.com/

131 packages can be updated.
67 updates are security updates.

Last login: Thu Oct 24 15:18:34 2013 from ubuntu.local

Solution 2

This happens in UBUNTU because, by default only openssh-client is present. To access ur remote Ubuntu, you'll never ssh server running in remote machine. Just install server.

sudo apt install openssh-server

Solution 3

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 [email protected]' 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 the 123.2.3.4 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:
62,152

Related videos on Youtube

gpuguy
Author by

gpuguy

Updated on September 18, 2022

Comments

  • gpuguy
    gpuguy over 1 year

    I disabled the firewall with sudo ufw disable, I can ping the server, the server can ping me but I can't ssh to it:

    root@ubuntu:/home/acme# ssh 192.168.1.6 ssh: connect to host
    192.168.1.6 port 22: Connection refused
    

    I removed ssh and reinstalled :

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

    But still ssh is not working and I get the error

    connection refused

    How do I tackle this issue?

    Here are some other stuff I have tried so far:

    root@ubuntu:/home/acme# sudo service ssh start
    start: Job is already running: ssh
    
    root@ubuntu:/home/acme# ps aux | grep ssh
    acme      6548  0.0  0.0  12576   320 ?        Ss   04:09   0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session gnome-session --session=ubuntu
    root     22219  0.0  0.1  50040  2852 ?        Ss   05:10   0:00 /usr/sbin/sshd -D
    root     22277  0.0  0.0   8116   896 pts/0    S+   05:17   0:00 grep --color=auto ssh
    

    Update for future visitors

    removing and reinstalling ssh on the server worked for me :

    sudo apt-get remove openssh-client openssh-server
    sudo apt-get install openssh-client openssh-server
    
    • Admin
      Admin over 10 years
      I assume you reinstalled ssh on your server (192.168.1.6)? Please share it's configuration file.
    • Admin
      Admin over 10 years
      Can you test SSH locally on the server? eg ssh localhost
    • Admin
      Admin over 10 years
      @AndrejsCainikovs though the issue is solved , but can you tell me where do we get that configuration file?
    • Admin
      Admin over 10 years
      SSH server configuration file is located at /etc/ssh/sshd_config. Please answer your own question and mark it as solved later on.