I have setup key-less login at a remote server. I use the remote server for tunneling my data. I want my local system to ssh into the remote server at boot time automatically.
I tried the solutions suggested in the following links but none of them worked for me:
- How to launch a SSH tunnel with upstart
- How do I make a script run upon startup of the Ubuntu machine?
- Autossh with Ubuntu Upstart
I did what was mentioned in those posts. The autossh
command should open a port (9090
in my case) so that I can tunnel my traffic. After applying each of those methods, I restarted the PC and upon reboot I ran nmap
to see if the particular port was listening or not. Sadly, in each case the port was still closed so I have to manually enter the command at terminal every time I reboot my PC.
Can some one help me? Do note that the remote server and my local system are both running Ubuntu 14.04, and the local system has no GUI installed.
Best Answer
I have this little script kept in
~/bin/infinite_ssh
(1):this is connecting to the
remoteserver
and creates a backward tunnel so that in the remote server I can ssh my desktop by usingssh -p 2222 localhost
. Your application may, obviously, vary. Theremoteserver
is defined in~/ssh/config
so that you can login without a password, and hasKeepAlive on
option.Then you can call it from
/etc/rc.local
withso that it starts as your user at boot time, in background.
Footnotes:
(1) obviously, you need to give the script execution permission...
chmod a+x ~/bin/infinite_ssh
.