0

I have a raspberry pi behind a NAT and a remote virtual server. I want to be able to access the pi via remote shell from outside.

To achieve this I created an executable file /etc/network/if-up.d/ssh_tunnel on the pi containing

sudo -u myname ssh -fCNR *:2222:localhost:22 [email protected]

While this command works, when executed as root from the command line, it doesn't work on startup.

Redirecting stderr to a file gives me

ssh: connect to host 1.2.3.4 port 22: Network is unreachable

What could I do better?

1 Answer 1

0

The Script needs to be run after dhcp is finished, most likely the module you want is dhcpcd. Another option would be to configure a static IP on your Pi.

1
  • To complete your answer: I put the code into /etc/dhcp/dhclient-exit-hooks.d/ as suggested in askubuntu.com/a/1005738
    – jederik
    Dec 26, 2018 at 18:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .