Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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. Can anyone please help me resolve this problem.

share|improve this question
1  
Could you please verify, and then update the question, the following a) that your friend has the openssh-server installed and running, b) that it is listening on the default port 22 and c) that you have gotten the right ip address. –  andol Feb 16 '12 at 7:09
    
and d)that a firewall is not blocking the connection –  hbdgaf Feb 16 '12 at 7:16
    
Thank you for your response andol the problem is with the ssh-server was not installed. Now I have done it and it is working properly. –  samanth Feb 16 '12 at 9:33
add comment

2 Answers

I normally when in a LAN or not in a LAN I do this:

  1. First install openssh-server in 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 accesible. The fastest way is to send it a ping.

ping 192.168.0.100 assuming the IP is the IP 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 in your friend's PC. Normally his own account will do.

ssh friend@192.168.0.100 where friend is your friends user name.

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

share|improve this answer
    
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. –  ruffEdgz Feb 16 '12 at 16:56
    
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. –  Luis Alvarado Feb 16 '12 at 16:59
    
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. –  ruffEdgz Feb 16 '12 at 17:07
    
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. –  Luis Alvarado Feb 16 '12 at 17:12
add comment

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

so ssh -vvv username@host

hope this helps along with the other answers

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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