Jump to content

Autossh on Raspberry Pi


Recommended Posts

So it seems I am missing something here and I can't seem to figure out what I am doing wrong so any help here would be greatly appreciated.  I have a Raspberry Pi 3 running Raspbian Jessie Lite and I have a VPS that I want it to automatically connect to.  I am having a couple of issues and the first one is when I issue the following command nothing happens and by that I mean a netstat -antp still shows the port closed on the VPS. For security purposes I in the example I am using random port numbers but when I give the command I am using the actual ports that my ssh is running on.

autossh -i secretkey.pem -f -N -M 0 1111:localhost:4444 user@VPS -p 5555 -o "ServerAliveInterval 360" -o "ServerAliveCountMax 5"

When I issue the following command though autossh works and makes an ssh connection but because I have removed the -f flag it opens a connection in my terminal and once I exit the terminal it closes the connection and the port on my VPS

autossh -i secretkey.pem -M 0 1111:localhost:4444 user@VPS -p 5555 -o "ServerAliveInterval 360" -o "ServerAliveCountMax 5"

The next issue is that when I put the same command from above into a cronjob with @reboot no connection is made to the VPS when I reboot the Pi.

Any help with this is greatly appreciated.

Link to comment
Share on other sites

49 minutes ago, digininja said:

Do you know that @reboot is working in Cron? It seems to be quite temperamental




I'd put the command in rc.local or in a proper init script rather than rely on cron.

@reboot is working as I have some other stuff working in there but I will try the rc.local this weekend.  Thanks for the help.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...