you can make a reverse SSH with the -R arg (i wrote an article in french about this here ) and cron or make a service with.
here the stuff translated
user@mynewRaspberry :~$ ssh -R 61337:localhost:22 z8po@z8po.dyndns.info
after you can login it from another place, here in example from z8po.dyndns.info
z8po@hive :~$ ssh z8po.dyndns.info -p 61337
Next let's use a while loop in your script to check the ssh is forever relaunch.
while true do ssh -R 61337:localhost:22 z8po@z8po.dyndns.info done
you can maintain your connection with a keep alive on a ssh client or a server, add to /etc/ssh/sshd_config or ~/.ssh/config the folowing line
ClientAliveInterval 60
Don't forget to use rsa key insteed of paswsrod for auto login without prompt, or if you really want to use password, change the ssh command with user:password@ip but it is quite less secure.
First method Cron it
make a script checking if allready launched, in /home/USER/autolauncher.sh
#!/bin/sh
if ps -ef | grep -v grep | grep yourscript.sh ; then
exit 0
else
while true do ssh -R 61337:localhost:22 z8po@z8po.dyndns.info done
exit 0
fi
and edit you crontab
crontab -e
add it after the other crons jobs; every 5 min launch the previous script (which will not work if already running)
*/5 * * * * /home/USER/autolauncher.sh
Second method : service at startup
create or copy the script in init.d add the commands in to it using vi:
sudo nano /etc/init.d/autolauncher.sh
make it executable
sudo chmod +x /etc/init.d/autolauncher.sh
update-rc.d to create and configure start:
sudo update-rc.d autolauncher.sh defaults
now you have two methods to make your rasperry trying to connect
Though I don't understand... why is there a while loop in the cron script? – tekknolagi – 2013-06-01T17:51:24.070
1because of service at startup, it will launch one time, and if crash, relaunch it etc... – z8po – 2013-06-02T14:21:59.800