8

I am new to ssh on linux. I have two computers connected on a switch. The first one is 192.168.1.2 and the second is 192.168.1.3. When I use the ping command I got a reply and everything is good, but when I use ssh from the frist computer ssh -v user@192.168.1.3 it gives me,

OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 192.168.1.2 [192.168.1.2] port 22.
debug1: connect to address 192.168.1.2 port 22: Connection timed out

I have ssh installed on both machines. Any ideas on how I can fix this problem?

1

Check these things:

  • Port 22 open and can receive connections
  • Make sure OpenSSH or another SSH process is running on the server
  • Make sure the SSH configuration file is given the appropriate values
  • 7
    mmm. man sshd_config |grep -i appropriate comes up empty on all my linux boxes, and Solaris too – sehe Jul 14 '11 at 0:00
  • @sehe The file isn't located under /etc/ssh/? – norway28 Jul 14 '11 at 0:20
  • 3
    This made me <headdesk/> even while in bed. Sarcasm fail. What I (mockingly) suggested, is the documentation does not contain info on the appropriate (sic) settings – sehe Jul 14 '11 at 0:34
  • thanks for all,actually port 22 was close so I have inserted this command [code] iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 22 -j ACCEPT [/code] – sam Jul 14 '11 at 1:46
  • Thanks @norway, I am facing the same problem. How can I Check those things ? I am using a Shared Hosting. Thanks. – abu abu Mar 7 '17 at 6:21
3

Troubleshooting tips:

  • Can you ssh localhost on the server?
  • Are users allowed? (AllowUsers setting)
  • Do you bind to the external NIC? (look for ListenAddress 0.0.0.0 or ListenAddress ::)
  • Are you running on port 22? (Port)

    • Basically check /etc/ssh/sshd_config.
  • Added: you can use netstat -tlpn | grep 22 to find out what programs (if any) are listening on port 22 (run as root to see the process names) .

Also, consider using an explicit port connect instead of ping (e.g. nmap -PN remote -p22 or even just telnet remote 22)

1

I know, the question is about the private network, but I had the similar output when I was trying to access a device via the Internet. After googling, I found this question; so, even though, it might not answer the question, others might find my answer helpful. In my case, it turned out that my ISP is blocking the port 22/TCP.

If you are trying to access a device via the Internet, there are basically five possibilities:

  1. The network connection might not be going on between the machines. Try pinging the server machine's IP address. If you can't receive any packets, then try checking the network connection on both machines.
  2. The SSH server might be misconfigured. Try SSHing into the device locally (from the same device and user to the same device and user) via:

    ssh localhost
    
  3. If the server machine is connected to the Internet via a router, the port forwarding might not be configured appropriately. So, check the port forwarding configuration on your router.

  4. The local firewall on the server machine might be filtering the incoming connection out. Try allowing incoming connections on the 22/TCP port in your firewall's rules or temporarily disabling firewall altogether.
  5. One or both of the ISPs might be filtering the connection out. Try changing the port on the server to something like 2222, restarting the SSH server, and SSHing using the new port. You can specify the port on the client machine via -p option in the command like this:

    ssh USER@HOST -p PORT
    
0

First, check if SSH is running on the receiving end. Login to the remote machine and try to ssh to localhost (ssh to the same machine you are on).

ssh -v myUserName@localhost

This should prompt for your password and then should log you into the same machine. If this does not work, that means that this host does not have SSH enabled. Enabling "remote login" on this server should fix the problem.

If however you were able to ssh from the target server into itself successfully, then the issue is likely somewhere in the middle. Your next thing to check is firewalls on the source host to make sure they are not blocking ssh.

  • 1
    I call hand-waivy: Enabling "remote login" doesn't actually mean anything. Fixing the problem should also enable "remote login", FWIW – sehe Jul 13 '11 at 23:58
0

If openssh-server is already installed, could be firewall blocking...assuming you've got ufw enabled.

If you are going from machine 192.168.1.2 to target machine 192.168.1.3. On target machine do... Sudo ufw allow from 192.168.1.2. And visa versa would be handy

-1

Check following things:

1) Run nmap localhost and check port 22 status

2) On your second computer with which you want to connect through ssh, perform ssh localhost

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.