0

I have a pi in my local network, and I sometimes want to connect to it via ssh. However, the pi always has a different IP-address, so I look it up beforehand each and every time. Is there a way for me to connect to my pi without looking up it's IP address? I could assign a static IP in my local network, but I'm not sure if that's good practice or whether there are better solutions. If there aren't, it would be great if s.b. could explain how to assign a static IP to my pi in my local network. Thanks a lot in advance.

PS: I am looking to connect to my pi via ssh programmatically. So a software solution that finds the IP address might not do.

R. Kohlisch
  • 103
  • 5
  • 1
    Have you tried `hostname.local`? Some routers also use .local domain (`hostname.local`). – Dirk Dec 04 '18 at 14:35
  • I know it has been solved already, but for completeness: That last bit of my comment above should have read `.home`: `hostname.home` – Dirk Dec 04 '18 at 15:00
  • 1
    Possible duplicate of [How to get the Raspberry Pi's IP address for SSH](https://raspberrypi.stackexchange.com/questions/6714/how-to-get-the-raspberry-pis-ip-address-for-ssh) or https://raspberrypi.stackexchange.com/q/12440/78211 or https://raspberrypi.stackexchange.com/q/38/78211 – Fabian Dec 04 '18 at 16:47

2 Answers2

2

I don't know if you've changed some settings on your Pi or not, but recent "stock" Raspbian will have the Avahi service installed & configured for the SSH server. All being well you should be able to say ssh pi@raspberrypi.local from within the local network, where raspberrypi is the hostname you've given your Pi, and connect.

If it's not set up on your Pi then you can follow the instructions on eLinux here to get it working: the Avahi stuff is a little bit further down after the section on assigning a static IP (which you can follow instead if you prefer).

Roger Jones
  • 1,479
  • 5
  • 14
2

in the terminal : sudo raspi-config then with 'N1 hostname' give the name you want to your pi : mypi reboot then you can connect in ssh with : ssh pi@mypi.local

V.Hure
  • 31
  • 3
  • @R.Kohlisch An unmodified Raspbian image comes with hostname `raspberrypi`. Why it does not work with `ssh pi@raspberrypi.local`? – Ingo Dec 04 '18 at 23:01