0

I have connected a raspberry pi 4 running ubuntu 20.04 to my local LAN over wifi.

From my laptop I can SSH to the raspberry just fine with:

$ ssh ubuntu@192.168.0.47
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-1022-raspi aarch64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
 ...

Instead of having to type that IP each time I would like to be able to SSH to it using the hostname: rasp01. I have found this guide:

https://thepihut.com/blogs/raspberry-pi-tutorials/19668676-renaming-your-raspberry-pi-the-hostname

that I have followed. After I have rebooted the raspberry pi and logged into it I have this:

ubuntu@rasp01:~$ hostname
rasp01

ubuntu@rasp01:~$ cat /etc/hosts

rasp01 localhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

ubuntu@rasp01:~$ cat /etc/hostname 
rasp01

But when I try to use that hostname when I SSH to the raspberry from my laptop on the same LAN (also running ubuntu) I get:

$ ssh ubuntu@rasp01
ssh: Could not resolve hostname rasp01: Name or service not known

$ ssh ubuntu@rasp01.local
ssh: Could not resolve hostname rasp01.local: Name or service not known

$ ssh ubuntu@rasp01.local.
ssh: Could not resolve hostname rasp01.local.: Name or service not known

What am I missing?

1
  • Unfortunately, questions about host/server configurations and protocols above OSI layer-4 are off-topic here. You could try to ask this question on Super User.
    – Ron Maupin
    Dec 11 '20 at 23:32
1

The Super User section of Stack Exchange is focused on power users. It's a good resource for SOHO networking questions such as yours. This site is for network engineering professionals, so your question is actually not on-topic here.

However, there are several ways to do what you want, among them:

  • Add an entry to /etc/hosts on your workstation mapping rasp01 to 192.168.0.47
  • Configure your SSH ~/.ssh/config file, adding a host entry
  • Setup a DNS service for your home LAN, especially if your router supports integration with its DHCP server

Not the answer you're looking for? Browse other questions tagged or ask your own question.