It certainly doesn't make scene that you can make an SSH connection from your own PC and not a different PC on the same network after installing openssh-server (assuming you haven't changed the default settings and there's no magic on the network stopping the connection from getting through).
The first thing that I would do is check to make sure SSH is listening on all Ethernet adapters (and not just localhost). You can do this with netstat
, listing numbers rather then service names (-n) using TCP (-t) that are listening (-l) and passing the results to grep
searching for :22
which is the port that SSH listens on by default:
netstat -ntl | grep :22
You should get the following result:
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
If you don't get that result then that's possibly your first problem. Checking that the SSH server has in fact started (restart with sudo server ssh restart
) is the first thing I would try (but that's probably not the case for you as you can connect from localhost). The second thing I would look at is the SSH server configuration is in order.
If that is the result that I got from netstat
then I can assume that the SSH server is listening on all Ethernet adapters which would mean that connections from other PC on the same network should work.
The next thing I would look at is the the IP address of the PC to ensure that I'm specifying the correct IP address from the PC that I'm trying to connect from. ifconfig
should give me the information that I need.
On my PC, ifconfig
gives me:
eth0 Link encap:Ethernet HWaddr 00:26:9e:e8:cf:31
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:42 Base address:0xc000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:4239 errors:0 dropped:0 overruns:0 frame:0
TX packets:4239 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1341552 (1.3 MB) TX bytes:1341552 (1.3 MB)
wlan0 Link encap:Ethernet HWaddr c4:17:fe:3c:aa:d7
inet addr:192.168.1.66 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::c617:feff:fe3c:aad7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:54149 errors:0 dropped:0 overruns:0 frame:0
TX packets:24983 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:29122251 (29.1 MB) TX bytes:4707094 (4.7 MB)
This shows me that my eth0
doesn't have an IP address (because it's not connected) and that my wireless adapter, wlan0
has the IP address 192.168.1.66
. This is the IP address that I need to use to connect from another PC on the same network.
On another PC, assuming I have logged in with the same username as I have on the "problem" PC, I would connect from a terminal with:
ssh 192.168.1.66
Still doesn't work?
Next thing to try is check if there is any kind of network communication between the PCs. Trying pinging the "problem" PC from the other one. If you can't get a ping reply then it's probably not an SSH issue but rather a network issue.
Another thing you could try... Some months back, I had a problem trying to print to my wireless printer from my laptop. Turned out to be the wireless router causing the problem. After a router reboot printing was up and running again. Have you tried rebooting your router?
Still no luck?
Ok, now we'll try sudo tcpdump
on machine A. We want to dump all packets with the source IP address 192.168.1.33 (machine B) that are coming in on port 22 over eth0
(assuming your network adapter is eth0
):
sudo tcpdump -i eth0 src host 192.168.1.33 and dst port 22
Now on machine B try:
ssh 192.168.1.22
Does tcpdump
produce any output?
We could also try telnet
from machine B to try to connect to port 22 on machine A:
telnet 192.168.1.22 22
This should produce something like:
user@machineb:~$ telnet 192.168.1.22 22
Trying 192.168.1.22...
Connected to 192.168.1.22.
Escape character is '^]'.
SSH-2.0-OpenSSH_5.8p1 Debian-1ubuntu3
Can any other computers connect to machine A?
Can machine B connect to any other computers?
ping 192.168.1.22
. If you don't get a reply then SSH is probably not the problem, its probably some other network issue.