Autossh for Synology Diskstation

by kacang bawang

This article is about compiling autossh for Synology Diskstation devices. The resulting pre-built binary for aarch64 will also be provided for download at the end of the post.

Autossh is a binary wrapper for regular ssh that takes care of things related to keeping track of whether the connection is still intact, and restart it if it isn’t so. You need it to run long-lasting ssh tunnels, which will invariably crap out and need to be restarted sooner or later. In the case of the Diskstation, perhaps the most obvious use-case is to maintain a tunnel to a reverse proxy somewhere on a VPS, such that your Diskstation can be accessible from the wider internet, via a proper domain with a proper certificate.

After a quick search of the available packages, I did not see autossh among them. That means we have to build it. The most helpful resource in this regard is SynoCommunity. They have created an entire build environment that includes the tools to publish the resulting “app” in the “app store”. Here we will deal with only the first part of the process, that is, the cross-compilation. The reader is invited to continue from where I left off, and get this thing published. Unless I beat you to it, haha.

The environment. The process is described pretty well here, so I will just say that I followed it and installed docker from the ppa’s via apt-get. Installation was smooth (Mint 18.04). Don’t forget to

The compilation. The build system expects a makefile in the /spksrc/cross/[your_package_name] directory. Just follow suit from other makefiles in the /cross/ directory. Here is what I ended up with.

The other quirk is the configure script for autossh check the location of the ssh binary. There is probably a flag to force this, but I did not find it immediately (let me know if you figure it out and I will update the makefile). Instead, I just did

before compilation. That path is where the ssh binary is on my Diskstation.

With that, it should compile and produce a binary like this: autossh.zip. Now, you should upload it to your Diskstation and run it. See if it outputs the welcome message. If yes, then great success, you can start using it. You may want to make it run at system start. At the time of this writing Diskstation uses upstart, so that’s the kind of script we will need to write. See autossh upstart script here.

UPDATE
Here is my init script