I recently started a robotics research project at my university with some fellow students, and I'm the programmer for it. We plan to use a Raspberry Pi 4 Model B as the "brains" of the robot. With the need for long-distance operations, I'm in the following situation:

  1. I will start with physical access to the RPi, which I will use to set up the SD card and OS for remote use.
  2. I will mail the RPi and accompanying power supply, an ethernet cable, etc to one of the mechanical team members for their continued design and assembly work.
  3. The team member will power up the RPi and connect the RPi at their home to the internet using the ethernet cable and a wall port, presumably (although other suggestions are welcome).
  4. I will SSH into this headless RPi and work on it from there.

How do I achieve this (preferably with as little technical work for the mechanical team member as possible)? How do I even get the IP address to connect the the RPi without physical access to it once I've mailed it? Is there a better way to do this entirely than what I was planning?

  • NOTHING you can do on the Pi is going to build port mapping into everyone's routers.
    – Milliways
    Commented Mar 28, 2020 at 3:15
  • @Milliways so will I need to have the mechanical guy ping the RPi and then give me its IP address so I can ssh?
    – Drake P
    Commented Mar 28, 2020 at 3:31
  • the RPi's IP address at the colleague's home will most likely be something like 192.168.x.y ... that is a non-routable IP address that is invisible to the outside world
    – jsotola
    Commented Mar 28, 2020 at 5:02
  • @jsotola So it is possible at all for me to SSH into an RPi in someone else's home?
    – Drake P
    Commented Mar 28, 2020 at 5:04
  • 1
    It seems using reverse SSH tunnelling you can just have the Pi “phone home”, as it were. Here is an article explaining: howtogeek.com/428413/… However I have never done it so I don’t want to write an answer about it. For this to work you do need to have a static IP yourself.
    – 11684
    Commented Mar 28, 2020 at 10:30

1 Answer 1


Local address

They (the mechanical team who access the raspberry pi) should configure their router to forward incoming port number 22 to the raspberry pi's local IP address which can be recognized by a simple command.

ifconfig eth0

It gives them the local IP address which is accessible on their local network. Also, the command below gives them just the IP address of eth0:

ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'

It would be better (to stop the loop of configuring) if they set a static IP address for the raspberry pi because the DHCP server may change the raspberry pi's address.

After that, you can access their internal network by their public IP address as their configuration on their router.

Public address & mail server

They can contact their Internet Service Provider to get a static IP address. If they do not do that, you can write a python script to get the public IP address by getting that via the command below:

curl icanhazip.com

Next, create a mail server to send the IP address if the public IP address changed. With the help of this step, if the public address has changed, you would be noticed by your email.


  • Would I need to add this python script to the RPi's .bashrc so it always runs on boot? And does this setup create any security concerns for the home network that the mechanical team member should be worried about or aware of?
    – Drake P
    Commented Mar 28, 2020 at 16:44
  • @DrakeP Yes, although, there are better approaches to enable/run a python script on system startup. In this case, check this link out. -- You will open the related port for email data communications. So, all your concentration should be about the way that you want to send the email data. Other security topics for this, is about how to secure the raspberry pi and not related to this configuration. Commented Mar 28, 2020 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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