I have a PC behind a NAT which makes a reverse 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 thsi 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 ym DigitalOcean server. This method works 100%.
However when I install the chrontab 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 cronejobs I tried as roots cronejobs. 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 chrontab a several minutes before the current time and waited for it to execute.
24 12 8 * * * bash /home/user/rev.sh 24 12 8 * * * /home/user/rev.sh
these did not execute either.
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.