The way the network configuration has been done at my office makes it impossible to do a port forwarding to access a specific machine outside the network. I figured out that it could be possible to perform a reverse ssh port forwarding.
1. You need a server machine that will accept ssh connections : Install ubuntu(because its the easiest to install) on a machine at home. Make sure you do a port forwarding on your router if you have to and map a dynamic dns from dyndns.org on that machine.
apt-get install openssh
2. The host machine at my office(Linux Based) would need to verify the connection to the outside server every time because the IP address of the office is dynamic and the server at your place is not on all the time.
Write a small script remote.sh in /home/username that would do the following:
COMMAND=”ssh -N -f -R 2210:localhost:22 firstname.lastname@example.org”
pgrep -f -x “$COMMAND” > /dev/null 2>&1 || $COMMAND
Add that script to your crontab(runs it every 5 minutes)
*/5 * * * * /bin/sh /home/username/remote.sh
3. Perform RSA key pairs
Because the two machines need to authenticate before communicating with each other, we will need to make an automatic login via rsa public/private key pairs.
ssh-keygen -t rsa (Run this on the host machine)
when all steps of the keygen are done,(Press enter until its over, no need to input anything)
scp id_rsa.pub email@example.com:~/authorized_keys
And you’re done. You should now be able to login to the host machine by login in on the server machine and running “ssh -p 2210 localhost” when logged in as root.