I'm currently working on a project using 4 raspberry pi as a cluster. These pi's are attached to each other through a local network, but I need to be able to send command to it from a host computer over wi-fi. Hence they are also configured on the same wi-fi network as the host.
My problem is, is that I can't connect to them through ssh with just their hostname from my laptop. If I use their IP address it works fine, but i'm on a eduroam network so the IP addresses change every 24 hours, so I can't make a script connecting to them based on IP's.
I've tried both ssh and ping using to hostname as such:
ping my_hostname.local
ssh my_hostname.local
ssh pi@my_hostname.local
All of these result in a "Name or service not known" error.
Now having searched the internet far and wide there were several problems that could cause this.
- Ssh is not enabled on the raspberry pi.
- Avahi daemon is not running.
- Avahi daemon is running and should be turned off. (This was a posted solution for post Jessie distro's)
None of these solutions worked though.
The Laptop is running CentOS 7 and the pi's are on the latest Raspbian Stretch release
EDIT: Verbose output of SSH connection:
[mpuls@mitch ~]$ ssh -v epnpi1
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
ssh: Could not resolve hostname epnpi1: Name or service not known
[mpuls@mitch ~]$ ssh -v epnpi1.local
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
ssh: Could not resolve hostname epnpi1.local: Name or service not known
[mpuls@mitch ~]$ ssh -v pi@epnpi1.local
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
ssh: Could not resolve hostname epnpi1.local: Name or service not known
[mpuls@mitch ~]$ ssh -v pi@epnpi1
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
ssh: Could not resolve hostname epnpi1: Name or service not known
/etc/hostname
and/etc/hosts
contain? – Milliways Mar 2 '18 at 11:41