Dimanche, 5 février 2017

My old NAS that I use for backups is now over 10 years old, and while it
still works and faithfully backs-up my files every night, it has an always
increasing probability to fail.

I decided to replace it with a Buffalo Linkstation 210, that offers 2 TB of
space for 140 EUR, making it cheaper than building my own device, at the risk
of not being able to use it the way I want it, being a commercial device that
wasn't designed with my needs in mind.

The way I want to use the NAS is that it boots automatically at a given
time, after which the backup script on the desktop starts, transfers the
needed files, and puts the NAS to sleep mode again. That last feature was
available on my previous device, but not anymore on the LS210. Hence the need
to make it do my bidding.

Moreover, the Web UI for administrating the LS210 is horribly slow on my
desktop due to bad Javascript code, so the less I have to use it, the better.

The device

The way to gain SSH access seems to vary depending on the exact version of the
device and the firmware. Mine is precisely a LS210D0201-EU device with
firmware version 1.63-0.04, bought in January 2017.

Initial setup

I found instructions on
the nas-central.com forum. It relies on a Java tool called
ACP_COMMANDER
that apparently uses a backdoor of the device that is used for firmware
updates and whatnots, but can apparently be used for running any kind of shell
command on the device, as root, using the device's admin user's password.

Let's assume $IP is the IP address of the device and "password" is the
password of the admin user on the device (it's the default password).

You can test that ACP_COMMANDER works with the following command that runs
uname -a on the device:

java -jar acp_commander.jar -t $IP -ip $IP -pw password -c "uname -a"

It will output some amount of information (including a weird message about
changing the IP and a wrong password ), but if you find the following in the
middle of it, it means that it worked:

One nasty feature of the device is that the /etc/nas_feature file gets
rewritten on each boot through the initrd. One last step is then to edit
/etc/init.d/sshd.sh and to comment out near the beginning of the file the
few lines that check for the SSH/SFTP support and exit in case SSH is not
supported: