1

I try to set autossh to run at boot adding it to /etc/rc.local but I am unable to even get it to run in the background.

This is the crucial part of my config file:

Host remotehost.com
  LocalForward 127.0.0.1:8082 127.0.0.1:8082
  LocalForward 127.0.0.1:8000 127.0.0.1:80
  LocalForward 127.0.0.1:10001 127.0.0.1:10001
  LocalForward 127.0.0.1:12001 127.0.0.1:12001
  Port 9922

This command works:

autossh -F /home/[username]/.ssh/config -i /home/[username]/.ssh/id_rsa remotehost.com

But, if I add the -f option

autossh -f -F /home/[username]/.ssh/config -i /home/[username]/.ssh/id_rsa remotehost.com

it won't.

As you see I am only using absolute pathes so it should not be this problem.

This is what my log says:

2014/04/22 12:09:07 autossh[4367]: checking for grace period, tries = 0
2014/04/22 12:09:07 autossh[4367]: starting ssh (count 1)
2014/04/22 12:09:07 autossh[4367]: ssh child pid is 4368
2014/04/22 12:09:07 autossh[4367]: check on child 4368
2014/04/22 12:09:07 autossh[4367]: set alarm for 600 secs
2014/04/22 12:09:07 autossh[4368]: execing /usr/bin/ssh
2014/04/22 12:09:07 autossh[4367]: check on child 4368
2014/04/22 12:09:07 autossh[4367]: ssh exited with status 0; autossh exiting
2014/04/22 12:09:07 autossh[4367]: expired child, returning 2
1

Oh. Silly me. This is covered in the manual even though I missed it. I should have added the -N-switch. This is what I put in in rc.local and which works:

su [username] -c 'autossh -f -N -F /home/[username]/.ssh/config_tunnels -i /home/[username]/.ssh/id_rsa remotehost.com

[username] is of course exchanged with my username.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.