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.

| improve this question | | | | |

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).

| improve this answer | | | | |

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

| improve this answer | | | | |
  • @R.Kohlisch An unmodified Raspbian image comes with hostname raspberrypi. Why it does not work with ssh pi@raspberrypi.local? – Ingo Dec 4 '18 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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