1

My current setup is that I have multiple Raspberry pis connected to my laptop through a network switch. None of the pis are connected to the internet. I want to broadcast commands to all of them to use a camera so want to use Terminator through Ubuntu on Windows.

If I ssh into the pi from PowerShell using ssh -X pi[i]@rpi[i].local, where [i] represents the number of my pi, I can get access but broadcasting commands is not an option. When I enter Ubuntu, and subsequently terminator or tmux, I cannot get access through ssh and the error message is:

ssh: Could not resolve hostname rpi2.local: Temporary failure in name resolution

When I unplug the cable connecting my laptop to the pis the error message does not change.

Has anyone got an idea as to what the problem might be and why I cannot connect through Ubuntu, but powershell works fine?

Paul
  • 11

1 Answers1

1

Since you mention that the Pi's are accessible from the Windows host but are not on the Internet, I'm going to make an assumption that they are either on a separate VLAN or have firewall rules to prevent access from devices outside the local network.

However, Ubuntu running on WSL2 is actually on a separate network from the Windows host. Its network is running behind a NAT'd, virtual Hyper-V switch.

This is likely why Ubuntu isn't able to connect to the Pi's. If that's the case, it's pretty much the converse of this question, but with similar answers.

This should also explain the fact that name resolution is failing. The .local TLD indicates that the Pi's are using mDNS. I'm not an expert in mDNS, but I'm guessing you'd need to be able to see them on the network in order to get their addresses that way. There's no "DNS server" that Ubuntu/WSL2 could use to perform the lookup for .local.

With that said, here are some possible options (and non-options):

Run the Windows SSH client through Ubuntu

This one started off as an afterthought that I was adding at the bottom of this answer, but it's possible that it may be the most straightforward solution.

Try:

ssh.exe -X pi[i]@rpi[i].local

Since Ubuntu can run Windows commands (as long as you append the .exe, you may be able to just utilize this form to accomplish your task.

One potential caveat is that you have the -X option in there for X11 forwarding. If you really do need this to forward to Ubuntu (via WSLg), then this may not be an option. I haven't tested it in that capacity.

WSL1

Unfortunately, for your use-case, you may not be able to use WSL1 here. Normally this is the easiest method for solving this type of problem. WSL1 operates as a pseudo-kernel translation layer directly to the Windows kernel. As a result, it shares the same network as the Windows host.

However, WSL1 doesn't support mDNS, so if you want to use WSL1, you'd need to either use the IP addresses or set up some type of resolver for those Pi addresses. This should be possible (IIRC) by editing the Windows host file (c:\Windows\System32\Drivers\etc\hosts).

If you want to use this method, see the other answer I linked above for how to backup and convert to WSL1.

SSH Jumphost through Windows OpenSSH server

I find having the Windows OpenSSH server to be a nice "Swiss Army Knife" for connectivity assistance. In this case, the concept is the same as in the other answer, but the flow is reversed.

After configuring the Windows OpenSSH server as mentioned in the other answer, you would be able to access your Pi's through something like:

ssh -X pi[i]@rpi[i].local -J $(hostname).local

If your username differs for Windows, you can use:

ssh -X pi[i]@rpi[i].local -J <windows_username>@$(hostname).local

What this does is first connect to the Windows OpenSSH server using mDNS ($(hostname).local), then uses that as a jumphost to the Pi. Since you will be connected to the Windows network after the "jump", the mDNS lookup for the Pi's should work as well. I tested this the best I could with my network.

Bridge network

As mentioned in the other answer, it may be possible to use an experimental feature to create the virtual network switch in bridged mode. You no longer need a Preview version of WSL, though - As long as you've installed WSL from the Microsoft Store, it should work.

PowerShell and/or Windows SSH client through Tmux

Similar to the first possible solution and untested for this particular use-case, but in theory you can use the concept in my answer here to handle this by running PowerShell (or the Windows SSH client) inside Tmux in Ubuntu.

NotTheDr01ds
  • 22,082