5

On my Synology NAS, I can't get SSH key authentication working. I have tried all the usual things (added to authorized_keys, edited sshd config, ...), and still haven't been able to get it working.

I'd really like to be able to run interaction-free transfers to my NAS with SCP.

Additionally, another IT friend I spoke to said he got it working a while back, but it was a big pain and doesn't remember how.

Has anyone gotten this working?

  • We are certainly glad you found a solution, but please don't put "Solved" in the title of your question. Within our community, the fact that you designated an answer as the official solution already shows us that the problem has been solved. Thanks for your help! – Run5k Mar 24 '17 at 18:34
  • Thanks for the tip Run5k. I'm relatively new, and still learning the unwritten rules. – Ben Yanke Mar 24 '17 at 19:11
  • Always glad to help. Thank you for the follow-up and the accepted answer! – Run5k Mar 24 '17 at 19:26
13

Although none of the other answers directly fixed it, I took some of their methods and combined them.

This is what worked for me on my Synology DS414slim, running DSM 6.1.

I logged in as admin and executed the following command (no need to fill in your username, it will work as-is):

This will set your home directory to 700 permission, owned by [you]:users.

homedir=$(eval echo ~$USER); 
sudo chown $USER:users $homedir -R;
chmod 700 $homedir; 
chmod 700 $homedir/.ssh/;
chmod 600 $homedir/.ssh/authorized_keys;
4

I got it working by following tips in the comments here: https://forum.synology.com/enu/viewtopic.php?t=90208

Short version, run chmod -R 755 ~. Dir perms were too permissive (?!) for ssh to use public key authentication. No idea if this causes other conflicts, but it works.

  • 2
    Although your answer is 100% correct, it might also become 100% useless if that link is moved, changed, merged into another one or the main site just disappears... :-( Therefore, please edit your answer, and copy the relevant steps from the link into your answer, thereby guaranteeing your answer for 100% of the lifetime of this site! ;-) You can always leave the link in at the bottom of your answer as a source for your material... – Donald Duck Mar 8 '17 at 17:23
  • 1
    I agree with Donald Duck. If you edit, Nobody, I'll set this as accepted answer. – Ben Yanke Mar 9 '17 at 18:43
  • And else you just add the answer yourself and mark it as community wiki. :) – Lexib0y Mar 23 '17 at 11:29
0

It works for me so it couldn't have been that hard to set up. I'm using a DS1812+ with DSM 6.0.2-8451 Update 5

Try creating a new user with read/write permissions on "homes"

Verify that you can ssh into the account with a password.

Either

  • add your id_rsa.pub to the ~/.ssh/authorized_keys
  • or ssh-copy-id new_user@synology_box

If it doesn't work, try using verbose mode: ssh -vvv new_user@synology_box. There might be something obvious there.

0

DSM 6

  1. chmod not only .ssh but also your home dir to 700
  2. chown not only .ssh but also your home dir to root:root

ex:

 sudo -i
 chown root:root /var/service/home/username
 chmod 700 /var/service/home/username
  • Um, that means I can't access my home directory if I set it owned by someone else, and give myself 0 permission. – Ben Yanke Mar 24 '17 at 16:46
0

I only had to do the following to get it working:

  1. Enable use of home directory using the web interface (Advanced settings)
  2. Change directory permissions for the home directory (NAS)

    sudo -i

    chmod -R 755 ~

  3. Then it was possible to generate keys and copy to the .ssh directory of that account (Client)

    ssh-keygen -t rsa

    ssh-copy-id account@synology_server

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.