Sonntag, 13. Oktober 2013

How to debug SSH path problems on Synology NASes

Recently I wanted to add just another backup job to my beloved DS212+ Synology NAS box. This job essentially does a bit of shell stuff via SSH on that box, also requiring to have some of the optware binaries in $PATH.

Well, first it didn't work out because apparently the optware binaries (more precisely /opt/bin and /opt/sbin) weren't in SSH's $PATH. However, I was pretty sure (and of course double checked!) that $PATH was tweaked correctly in the .ssh/environment file and that sshd was restarted after that.

To debug the issue further I just started another SSH instance on the Synology, using a different port + in foreground debug mode: 

/usr/syno/sbin/sshd -d -D -p 2222

On my client I then did this:

ssh -v root@<IP-to-my-NAS> echo \$PATH

Ah ha! The "Environment:" on the client side now told me that it indeed was picking up the wrong $PATH. But wait: Where did this come from?

Quick answer: Synology's start/stop script located at

/usr/syno/etc/rc.d/S95sshd.sh

kind of messes it up. For the sake of speed I believe it doesn't really terminate the old sshd instance and instead just drops existing connections. This is why changes to .ssh/environment do not get applied correctly after restarting the service.

Solution to all this now sounds pretty simple: Log in to DSM (DiskStation Manager) via web interface, go to system settings / terminal and (again) activate "SSH". This will (re-)start sshd the right way with the new environment settings picked up. Crappy, but works!


 




1 Kommentare:

Anonym hat gesagt…

The /usr/syno/sbin/sshd path doesn't exist anymore...

Kommentar veröffentlichen