suneetagera
Posts: 12
Joined: Mon Dec 07, 2015 10:28 am

Internet working over ethernet; SSH not working

Mon Dec 07, 2015 10:35 am

Hi All,

I recently updated and upgraded the OS on my Pi using commands "sudo apt-get update/upgrade".
Since then I am not able to ssh to my pi.

The pi is connected to the router/modem using a network ethernet cable, is able to get an IP address, can connect to the internet (which is how I did the updgrade), but I cannot connect to the pi from my laptop using an SSH client like putty.

Upon googling I found some folks advising to enable the SSH via raspi-config (since of late the SSH is disabled by default), but even doing that did not help.

Any suggestions?

Regards
Suneet

elatllat
Posts: 1337
Joined: Sat Dec 17, 2011 5:05 pm

Re: Internet working over ethernet; SSH not working

Mon Dec 07, 2015 8:30 pm

try ssh-ing from the pi to the pi
try posting some details like;

Code: Select all

ifconfig
nmap -p 22 127.0.0.1
ssh 127.0.0.1
SBC with 32GB RAM: https://hardkernel.com

FAQ : https://raspberrypi.stackexchange.com

Unanswered: https://www.raspberrypi.org/forums/search.php?search_id=unanswered

suneetagera
Posts: 12
Joined: Mon Dec 07, 2015 10:28 am

Re: Internet working over ethernet; SSH not working

Tue Dec 08, 2015 4:27 pm

elatllat wrote:try ssh-ing from the pi to the pi
try posting some details like;

Code: Select all

ifconfig
nmap -p 22 127.0.0.1
ssh 127.0.0.1
Hi

I tried your suggestions. Below are the outputs of the commands.

Image
Image
Image

All commands seem to work as expected; the first one shows Ip of the pi as 192.168.1.40 and the last one shows that ssh worked.

But when i tried putty from my Windows laptop
Image
I got the error as below
Image

suneetagera
Posts: 12
Joined: Mon Dec 07, 2015 10:28 am

Re: Internet working over ethernet; SSH not working

Tue Dec 08, 2015 4:44 pm

Oh dear, looks the images did not load in the previous reply.

Hi

I tried your suggestions. Below are the outputs of the commands.

https://www.dropbox.com/s/8kb7sr7r7gi63 ... g.jpg?dl=0
https://www.dropbox.com/s/elm8xg6s431q4dp/nmap.jpg?dl=0
https://www.dropbox.com/s/5hjof45mu09yed7/ssh.jpg?dl=0

All commands seem to work as expected; the first one shows Ip of the pi as 192.168.1.40 and the last one shows that ssh worked.

But when i tried putty from my Windows laptop
https://www.dropbox.com/s/9b25ynkvfdo0y ... y.jpg?dl=0
I got the error as below
https://www.dropbox.com/s/kiik3fn0ixd9h ... r.jpg?dl=0

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: Internet working over ethernet; SSH not working

Tue Dec 08, 2015 4:59 pm

Is your Window box on the same subnet? What is its IP?

nmap show 22 port as open on localhost. Can you also try this command:

Code: Select all

sudo netstat -ltnp
and

Code: Select all

sudo grep sshd /var/log/auth.log
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

suneetagera
Posts: 12
Joined: Mon Dec 07, 2015 10:28 am

Re: Internet working over ethernet; SSH not working

Tue Dec 08, 2015 5:26 pm

ripat wrote:Is your Window box on the same subnet? What is its IP?

nmap show 22 port as open on localhost. Can you also try this command:

Code: Select all

sudo netstat -ltnp
and

Code: Select all

sudo grep sshd /var/log/auth.log
Hi

Yes, the windows laptop is conencted to the wifi of the same router to which the pi is connected.
The windows box IP is 192.168.1.39 whereas the IP of the Pi is 192.168.1.40

The output of the commands you suggested is here:
output.jpg
output.jpg (38.5 KiB) Viewed 2514 times

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: Internet working over ethernet; SSH not working

Tue Dec 08, 2015 6:44 pm

Can you ping the rpi from the Windows box?

Try to look into auth.log to see any abnormalities. You can also increase the verbosity of sshd in the /etc/ssh/sshd_config file (LogLevel DEBUG) and restart sshd (sudo /etc/init.d/ssh restart)

Then check the log file after a failed connection:

Code: Select all

journalctl /usr/sbin/sshd
Also check for any firewall rules that could prevent the connection:

Code: Select all

sudo iptables-save
or
sudo iptables -L
Check also the TCP wrapper:

Code: Select all

cat /etc/hosts.deny
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

suneetagera
Posts: 12
Joined: Mon Dec 07, 2015 10:28 am

Re: Internet working over ethernet; SSH not working

Wed Dec 09, 2015 12:06 pm

ripat wrote:Can you ping the rpi from the Windows box?
No I cannot, nor can I ping from Windows box from the rpi. In both cases 100% loss of packets.
Try to look into auth.log to see any abnormalities.
I checked auth.log before and after trying a failed connection over putty.
[img]
auth-log.jpg
auth-log.jpg (49.16 KiB) Viewed 2420 times
[/img]
You can also increase the verbosity of sshd in the /etc/ssh/sshd_config file (LogLevel DEBUG) and restart sshd (sudo /etc/init.d/ssh restart)
I did that but ...
Then check the log file after a failed connection:

Code: Select all

journalctl /usr/sbin/sshd
... I couldnt find this command on the pi. There was no apt-get install for this command, and the alternative suggested by google was to update systemd via debian backports. Was not sure I should do that.
Also check for any firewall rules that could prevent the connection:

Code: Select all

sudo iptables-save
or
sudo iptables -L
The first command did not return any results.
The second command gave this
[img]
iptables.jpg
iptables.jpg (34.82 KiB) Viewed 2420 times
[/img]

I know its not a firewall issue because I use my Windows machine to ssh to linux machines on AWS.
Check also the TCP wrapper:

Code: Select all

cat /etc/hosts.deny
The file does not have any host entries, only some comments.

suneetagera
Posts: 12
Joined: Mon Dec 07, 2015 10:28 am

Re: Internet working over ethernet; SSH not working

Wed Dec 09, 2015 12:13 pm

I forgot to mention that looking at the auth.log i found two areas of concern. Not sure if it really is a matter of concern.

Code: Select all

sshd[2237]: debug1: Bind to port 22 on 0.0.0.0
sshd[2237]: debug1: Server listening on 0.0.0.0 at port 22
sshd[2237]: socket: address family not supported by protocol
Does the socket issue seem to be an issue?

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: Internet working over ethernet; SSH not working

Wed Dec 09, 2015 12:32 pm

suneetagera wrote:
ripat wrote:Can you ping the rpi from the Windows box?
No I cannot, nor can I ping from Windows box from the rpi. In both cases 100% loss of packets.
No need to look further. One of the two devices is segregated from the other for some reason. It's not a ssh problem but rather a networking problem. How are they connected to each other?
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

suneetagera
Posts: 12
Joined: Mon Dec 07, 2015 10:28 am

Re: Internet working over ethernet; SSH not working

Wed Dec 09, 2015 12:54 pm

ripat wrote:
suneetagera wrote:
ripat wrote:Can you ping the rpi from the Windows box?
No I cannot, nor can I ping from Windows box from the rpi. In both cases 100% loss of packets.
No need to look further. One of the two device is segregated from the other for some reason. It's not a ssh problem buth rather a networking problem. How are they connected to each other?
I have a broadband internet that comes to my house with a D-link modem/router as in the picture below. The router has 4 yellow ethernet ports, and the rpi is connected to the router via the red network cable. The router also broadcasts a wifi and my laptop is connected to that.
[img]
rpi setup.JPG
rpi setup.JPG (37.01 KiB) Viewed 2345 times
[/img]

As I mentioned earlier, I am able to use putty on my Windows laptop to ssh into linux machines on Amazon Web Services.

suneetagera
Posts: 12
Joined: Mon Dec 07, 2015 10:28 am

Re: Internet working over ethernet; SSH not working

Wed Dec 09, 2015 1:01 pm

You know what, I have got an idea. Maybe I should try connecting my laptop using another ethernet cable to the router and see I can ssh using putty. If yes, its got some setting with the wifi.

But I can only try this after half an hour coz my wife is hogging the TV (my monitor) now :cry:

suneetagera
Posts: 12
Joined: Mon Dec 07, 2015 10:28 am

Re: Internet working over ethernet; SSH not working

Wed Dec 09, 2015 1:56 pm

And Bingo! It worked when both the pi and the laptop were connected to the router.

So it was indeed some setting on the wifi which prevented the ssh to work. Crazy but true. Need to investigate that.

P.S. I have ordered a Wifi USB adapter which should come any time soon, after which I will test if putty works when both are connected to wifi.

ripat, thanks a million for pointing me in the right direction, and for taking the time out to answer my queries.

suneetagera
Posts: 12
Joined: Mon Dec 07, 2015 10:28 am

Re: Internet working over ethernet; SSH not working

Fri Dec 11, 2015 3:48 am

I got my wifi usb adapter today. Plugged it in the rPi, configured it, connected the laptop to the wifi and tried to login from my laptop using putty. Worked like a charm.

So funnily, the problem is only when the laptop is connected to wifi and rPi to the ethernet port. Wierd.

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: Internet working over ethernet; SSH not working

Fri Dec 11, 2015 6:44 am

suneetagera wrote:So funnily, the problem is only when the laptop is connected to wifi and rPi to the ethernet port. Wierd.
Not normal indeed. If both devices are on the same subnet (sharing the same subnet mask) they should be able to communicate. Depending on your skills you could try troubleshoot using tcpdump or Wireshark to trace the ICMP packets that ping uses and/or the ARP packets that are broadcasted on your subnet. Can you ping the laptop from the Pi?
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

suneetagera
Posts: 12
Joined: Mon Dec 07, 2015 10:28 am

Re: Internet working over ethernet; SSH not working

Fri Dec 11, 2015 6:51 am

ripat wrote:
suneetagera wrote:So funnily, the problem is only when the laptop is connected to wifi and rPi to the ethernet port. Wierd.
Not normal indeed. If both devices are on the same subnet (sharing the same subnet mask) they should be able to communicate. Depending on your skills you could try troubleshoot using tcpdump or Wireshark to trace the ICMP packets that ping uses and/or the ARP packets that are broadcasted on your subnet.
Skills are rusty (14 years ago used did Computer Networks on Linux!), but heres the chance to sharpen it. Will try your suggestions.
Can you ping the laptop from the Pi?
Nope. Pings fail both ways.

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: Internet working over ethernet; SSH not working

Fri Dec 11, 2015 8:13 am

What I would do is first check for any funky config on your router/switch like DMZ or firewall settings that could block network discovery (ARP). Then on the Pi, install tcpdump and:
  1. ping the laptop and check if its MAC address shows up in the Pi's ARP table:

    Code: Select all

    ip neigh
  2. If it does, ARP packets go through and the problem is probably on the laptop side or the router.
  3. if not, execute this command on the Pi. It will capture all ARP packet going through the Pi's ethernet interface

    Code: Select all

    sudo tcpdump -n -i eth0  arp
  4. open a new terminal window on the Pi and ping the laptop
  5. In the first terminal window you should see a "who-has <ip laptop>" ARP packet. If it is not followed by a reply "<ip laptop> is at <mac laptop>" this would confirm that the ARP request is sent, but either does not reach the laptop (router? Firewall? Vlan?) or the laptop reply is blocked on its way back to the Pi
  6. To further investigate, install tcpdump or Wireshark on the laptop and do the reverse process.
Happy network troubleshooting!
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

Return to “Troubleshooting”