Opened 5 years ago

Closed 5 years ago

Last modified 2 years ago

#12736 closed defect (not_a_bug)

Autossh does not work at boot-up with /etc/rc.local

Reported by: anonymous Owned by: developers
Priority: normal Milestone: Chaos Calmer 15.05
Component: packages Version: Trunk
Keywords: autossh Cc: BARRIER, BREAKER, (Bleeding, Edge, r34996)


I'm trying to start autossh when my router boots, by editing the /etc/rc.local file to include "autossh -M 20000 -N -R 150:localhost:22 root@ -i /etc/dropbear/id_rsa"

I have done this with older versions no problem, but the latest 'openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin' seems broke?

If I run a sniffer trace, I see my router initiate SSH, but the router terminates the connection immediately after recieving the SSH servers SSH key (almost like it rejects it).

If I run the command "autossh -M 20000 -N -R 150:localhost:22 root@ -i /etc/dropbear/id_rsa" manually from the command line, it works. It also works if I run a schedule via /etc/crontabs/root (every 5 minutes).

I just don't get why it works manually and via /etc/crontabs/root but NOT from /etc/rc.local. I only want it to start once on boot.....

I would be so grateful of any assistance!


Attachments (0)

Change History (9)

comment:1 Changed 5 years ago by anonymous

May be it searches the key at /.ssh - it was doing that at my router as well - i.e. ssh asks the user to accept the new key (to add it to known_hosts) and - since the user cannot answer - the key actually is rejected.

You can create a symbolic link from /.ssh to /root/.ssh, such that ssh will find the known_hosts at boot time.

comment:2 Changed 5 years ago by openwrt@…

I'm using the /etc/init.d script and get the same problem at start-up.

The last comment (ie. symlink /.ssh to /root/.ssh) fixes the problem for me.

comment:3 Changed 5 years ago by anonymous

For me it does work if I set localhost in "-R 150:localhost:22" to the local IP

comment:4 Changed 5 years ago by nbd

  • Resolution set to not_a_bug
  • Status changed from new to closed

set HOME=/root in your script and it should work.

comment:5 Changed 4 years ago by rene.reineke@…

nbd, would you please be so kind to clarify your solution? I couldn't apply it successfully. The autossh daemon still writes error:1 to the syslog and exists. Running from command line is just fine.

Thanks you for taking the time!

comment:6 Changed 3 years ago by maartenjd

Three things that might resolve the issue:

  1. Change to openssh-server instead of dropbear. Dropbear requires additional arguments for reverse ssh (see and cannot handle 'localhost' but needs a specific listen-address.
  1. Add -f (run in background); so -fN instead of -N, because it might stall execution of rc.local or cause a time-out of autossh.
  1. Make sure that is in the authorized_keys file on the remote machine (on in your case).

comment:7 follow-up: Changed 3 years ago by anonymous

Hello, seems that the format for unknown reasons shall be (note double hyphen --):

config autossh

option ssh '-i /PATH/TO/PRIVKEY -N -T -R REMOTEPORT: -- -y -l USERNAME -p PORT HOST'
option gatetime '0'
option monitorport 'MONITORPORT'
option poll '600'

comment:8 Changed 3 years ago by anonymous

Had to change the way anonymous (Comment 7) did. Else it didn't work.
Thank you

comment:9 in reply to: ↑ 7 Changed 2 years ago by operat0r

it seems the -- -y or/and ln -s /root/.ssh/ /.ssh worked for me .. .how the hell do you guys figure this out ? DGB ? im trying to get stunnel to work but it has NO errors or logs or anything ... THANKS!

Add Comment

Modify Ticket

as closed .
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.