SSH connection getting refused

35,204

Solution 1

Whether on a LAN or not on a LAN, I normally do this:

  1. First install openssh-server on all PCs that will be receiving the SSH connection:

    sudo apt-get install openssh-server
    
  2. Verify that the PC where I just installed openssh-server is accessible. The fastest way is to send it a ping.

ping 192.168.0.100 assuming the IP address is the IP address of my friend's PC. If it appears ok then I proceed with accessing to it. Remember that you need to use an account that already exists on your friend's PC. Normally his own account will do.

ssh [email protected] where friend is your friend's user name.

In a normal scenario this should be enough. Let me know if it works.

Solution 2

When you try and connect, use the -vvv switch to show debug information:

ssh -vvv username@host
Share:
35,204

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin almost 2 years

    I am new to linux and I am trying to establish a SSH connection with my friend's PC in the same LAN, but I am getting:

    ssh: connect to host 192.168.71.70  port 22: Connection refused
    

    Both ways are getting "connection refused." How can I fix this?

  • ruffEdgz
    ruffEdgz over 12 years
    I would say part of this answer is correct which happens to be 'install openssh-server' but the verification part has nothing to do with SSH. The best way to make sure that the ssh server is working is to: 1. Make sure its turned on (sudo service ssh status) 2. On the client computer, telnet to port 22 on the box with ssh server (telnet server1.example.com 22) or nmap the ssh server (nmap server1.example.com). Pinging only tells the client that you can get to them via ICMP but you can still SSH into a server and disable ICMP on the kernel level... Just my two cents.
  • Luis Alvarado
    Luis Alvarado over 12 years
    I have had friends installing SSH and spent an hour trying to connect to each other just to find out that they do not have any cables connected or do not have the network correctly setup to see each other. PING will just help with this and not think that SSH has the problem. Saves time.
  • ruffEdgz
    ruffEdgz over 12 years
    That's fine to add it to make sure for connectivity but you can do that PLUS make sure the ports are open by using nmap (sudo apt-get install nmap) from the client machine to the server machine as long as iptables isn't blocking all ports to the ssh server. I could be a bit picky on this but I want to make sure the correct checking is being done to verify that the service is actually on instead of just checking that a box is up and running.
  • Luis Alvarado
    Luis Alvarado over 12 years
    Well by default I have seen that it is enough installing the openssh server. The ports are opened by default. You would have to block them or have a device block the port. So if the OP did this it would be something additional specific to him/her. Apart from this, yes doing a check with nmap or any other network tools is a good idea in multiple cases.