I'm trying to set up git on Synology NAS via ssh. I've created git user, set private key authentication and installed git package. I can log in successfully using private keys and have git in /opt/bin working locally (on NAS).

To make it work I changed /etc/ssh/sshd_config to have:

PubkeyAuthentication yes                                                   
AuthorizedKeysFile      .ssh/authorized_keys                               

PermitUserEnvironment yes

But I still can't make it work remotely.

The problem seem to be in path used by ssh when I execute remote commands. I can confirm that because when I do

ssh gitowner@nas.home echo \$PATH

I get


which is different from interactive shell which is giving me:


I created .ssh/environment with following content


but it still doesn't resolve the problem. Looks like its contents is not read.

I tried with environment file permissions set to -rw------- and -rw-r--r-- but also to no avail.

What else I could be missing sshd(?) in configuration that prevents it from reading user environment?

  • Are the double quotes actually in your .ssh/environment file? – chepner Mar 21 '13 at 13:58
  • No not really, i'll update the question. I might have tried that in despair. – aliher Mar 21 '13 at 20:59

The solution was to try to run ssh in debug mode by running in on another port:

/usr/sbin/sshd -d -D -p 222

then running client with

ssh -v -p 222

and it became visible that it actually picks up environment. The problem was that NAS's ssh restart script

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

did't really restarted sshd, but only dropped existing connections and it failed to reread config. Once restarted, config was picked up and everything started to work.

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.