Can't connect through SSH from another PC on the same network Topic is solved

Having issues with your DietPi installation, or, found a bug? Post it here.
riccardo
Posts: 6
Joined: Sat Jan 19, 2019 8:47 pm

Can't connect through SSH from another PC on the same network

Post by riccardo »

I'm trying to get my Raspberry Pi Zero to work with SSH, to be able to access it remotely.
On a fresh install, I've got Dropbear installed, and if I try to connect from the Raspberry itself to its local address (something like ssh 192.168.1.200) it works, but if I try to do the same from another pc on the same network the connection times out.
Even worse than that, I cannot even ping its local address.
Any idea what could be happening?
User avatar
MichaIng
Site Admin
Posts: 2336
Joined: Sat Nov 18, 2017 6:21 pm

Re: Can't connect through SSH from another PC on the same network

Post by MichaIng »

Can you ping another machine in your local network? Perhaps the router denies local network access for the clients?
riccardo
Posts: 6
Joined: Sat Jan 19, 2019 8:47 pm

Re: Can't connect through SSH from another PC on the same network

Post by riccardo »

MichaIng wrote: Sun Jan 20, 2019 3:31 pm Can you ping another machine in your local network? Perhaps the router denies local network access for the clients?
I have another Raspberry on the network, which is instead connected through Ethernet, that I can ssh to without any problems.
From what I've been reading and experimenting it does seem like Dropbear doesn't even get any requests, as there's nothing in its log, but I don't know what could be preventing the connection to begin with: Dietpi doesn't have iptables nor ntf installed by default, I just checked.
User avatar
MichaIng
Site Admin
Posts: 2336
Joined: Sat Nov 18, 2017 6:21 pm

Re: Can't connect through SSH from another PC on the same network

Post by MichaIng »

If the connection was blocked by the RPi, you would see some connection log.

Could you check:

Code: Select all

systemctl
dmesg
The first to check if there are any system logs when you attempt to ping/connect.
The second to check if there are any kernel errors or such, wich might be related to failing connection.

But I am pretty sure that it is a network setup issue. Perhaps the WiFi network is separated from the Ethernet one. Are the IPs or the Pi Zero and the other Pi in the same IP range, e.g. 192.168.1.200 and 192.168.1.201?
riccardo
Posts: 6
Joined: Sat Jan 19, 2019 8:47 pm

Re: Can't connect through SSH from another PC on the same network

Post by riccardo »

MichaIng wrote: Sun Jan 20, 2019 4:37 pm If the connection was blocked by the RPi, you would see some connection log.

Could you check:

Code: Select all

systemctl
dmesg
The first to check if there are any system logs when you attempt to ping/connect.
The second to check if there are any kernel errors or such, wich might be related to failing connection.

But I am pretty sure that it is a network setup issue. Perhaps the WiFi network is separated from the Ethernet one. Are the IPs or the Pi Zero and the other Pi in the same IP range, e.g. 192.168.1.200 and 192.168.1.201?
I assume you meant journalctl? I checked systemctl for completeness sake, but nothing caught my eye there.
In journalctl I noticed that this section is repeated indefinitely:
Detected connection loss: wlan. Reconnecting
ifdown: unknown interface wlan
ifup: unknown interface wlan
Completed
Cannot find device "wlan"
Checking connection for: wlan via ping to
Usage: ping [...]
Usage: ping [...]
With [...] being the man page for ping.

Nothing that I could find on dmesg.

Both the Raspberries, meaning the one connected through Ethernet and the one connected through Wifi, have an address that looks like 192.168.1.X
I also have made it so that the router gives them certain pre-defined addresses so that it's easier to connect to them, but the problem exists both before and after that change.
User avatar
MichaIng
Site Admin
Posts: 2336
Joined: Sat Nov 18, 2017 6:21 pm

Re: Can't connect through SSH from another PC on the same network

Post by MichaIng »

@riccardo
Ah jep, meant journalctl of course :D.

Okay this helped, the WiFi monitor service seems to check a wrong interface name.

Please do:

Code: Select all

systemctl stop dietpi-wifi-monitor
ifup wlan0
In case the second command fails, e.g. you use an external WiFi device while the SBC has an internal one, try

Code: Select all

ifup wlan1
The WiFi monitor service gets the interface name via: sed -n 2p /DietPi/dietpi/.network
Could you check the output of this?

If is no integer, most likely 0 or 1, please try:

Code: Select all

/DietPi/dietpi/func/obtain_network_details
sed -n 2p /DietPi/dietpi/.network
And check whether now a valid integer is the output.

If this finally succeeded, you can re-enable the WiFi monitor:

Code: Select all

systemctl start dietpi-wifi-monitor
I will add updating the network info and checking valid interface name to the script for v6.20.
riccardo
Posts: 6
Joined: Sat Jan 19, 2019 8:47 pm

Re: Can't connect through SSH from another PC on the same network

Post by riccardo »

@MichaIng
I think there's a syntax problem:

Code: Select all

sed -n 2p /DietPi/dietpi/.network

says that it can't find the file, but if I move to /Dietpi/dietpi and then input

Code: Select all

sed -n 2p .network

it correctly outputs 0.

That being said, I have followed on your other idea and looked through my router's configuration and solved my problem by disabling wireless user isolation, which apparently does just what it sounds like it does: prevent any communication between wireless clients.
Thanks for your help, and if you need me to try any other thing on the raspberry pi zero to find out what's up with that internet interface bug ask away, I'd be glad to help!
User avatar
MichaIng
Site Admin
Posts: 2336
Joined: Sat Nov 18, 2017 6:21 pm

Re: Can't connect through SSH from another PC on the same network

Post by MichaIng »

Okay, great it works now. But wait:

The directory is called /Dietpi on your system instead of /DietPi (upper case P)?

Just checked, the syntax works well here, generally using the full path or cd to the dir and using file name only, has the same result.
riccardo
Posts: 6
Joined: Sat Jan 19, 2019 8:47 pm

Re: Can't connect through SSH from another PC on the same network

Post by riccardo »

Oh, that's my bad, I just mistyped...
It works with the absolute path too!
User avatar
MichaIng
Site Admin
Posts: 2336
Joined: Sat Nov 18, 2017 6:21 pm

Re: Can't connect through SSH from another PC on the same network

Post by MichaIng »

Okay good.

To prevent WiFi monitor from continuously reconnecting, not because of WiFi connection loss, but because of wrong WiFi interface or unplugged WiFi adapters, I made some change to the code: https://github.com/Fourdee/DietPi/commi ... 2bac88b02a

It updates now the network info first (check for network adapters and their connection state) and verifies that the found WiFi interface indeed exists, otherwise exits with error output to syslog.
Also when WiFi connection is lost, before attempting automatic reconnection (the intention of DietPi-WiFi-Monitor), it again verifies that the adapter is still plugged/present on the system, otherwise exits with error message to syslog.

But this means, whenever you plug off and on your WiFi adapter on running system, you need to re-enable the WiFi monitor through dietpi-config. But this makes perfectly sense.
Post Reply