I have a Raspberry Pi 2 running behind a firewall that prevents inbound SSH connections, so I get the Raspberry Pi to create a reverse SSH tunnel to an external server so that I can get an SSH connection to the Pi via that external server. The command the Pi runs is something like this:
#!/bin/bash
while true; do
ssh -R 19998:localhost:22 user1@www.user1website.pro
sleep 30
done
Then, on the server to which it connects, I can access the Pi using a command like the following:
ssh -X pi@localhost -p 19998
What I want is for the Raspberry Pi simply to boot to its terminal and then to run automatically this connection procedure for the user pi, i.e. not as root. What would be a good way to do this?
&seemed reasonable, but maybe it isn't. What do you think? – BlandCorporation Jun 06 '17 at 14:45nohup; if that doesn't work I think you will need to create a systemd service (there's aUser=option there). – goldilocks Jun 06 '17 at 17:18