I have a PC behind a NAT which makes a reversed SSH connection to my Digitalocean VPC. I utilise this reversed SSH connection from home to login to my office PC (I am authorised to do so) and copy files and do other important things.
Although not often, I noticed that my office PC restarts (due to power failures etc) and breaks the reversed SSH connection it has made with my VPC. In these kind of cases, I am unable to connect from my home PC to my office PC.
I run the following script to make the reversed connection + dynamic proxy to anonymise my traffic ( As I am not required to share browsing information) generated at the office PC.
autossh -CD 8080 -i digitalOcean -R 8081:localhost:22 root@IPofDigitalOceanPC
There is no way I can run this script again on my office PC upon a restart as I am not physically there. In order to solve this problem I installed the following crontab.
rev.sh file contains the above line. The certificate "digitalOcean" and rev.sh is located in
Ubuntu home. Therefore, when I execute
./rev.sh in my Ubuntu terminal I obtain a dynamic proxy and also access to my DigitalOcean server. This method works 100%.
However when I install the crontab in the following method, My ubuntu PC never makes a Dynamic proxy. I can see this because when I check this proxy from Google Chrome, it says proxy is refusing connection.
Here are the cronjobs I tried as root's cronjobs. I also tried these as a normal user, still they didn't work.
@reboot bash /home/user/rev.sh @reboot /home/user/rev.sh @reboot cd /home/user && ./rev.sh
I then installed a crontab a several minutes before the current time and waited for it to execute.
24 12 * * * bash /home/user/rev.sh 24 12 * * * /home/user/rev.sh 24 12 * * * reboot
These did not execute either.
I also tried
48 15 * * * bash /home/user/rev.sh >> test3 and
*/1 * * * * reboot -f >> test but the test3 and test have nothing. However the files has been CREATED!! by the crontab!
Please be kind enough to help me spot my mistake. There are many similar questions on this website on my issue. I have referred many answers hence but none of them seemed to help.