SSH without password for NON root

Hi, I’ve been able to get passwordless SSH access for root by following the info here  http://community.wd.com/t5/WD-My-Cloud/ssh-no-password/td-p/650367/page/2 but I have users other than root that can log into the system (one user per mac in the house and each laptop does an rsync to the my cloud for backups). I can’t get the passwordless access to work for users other than root.  I’ve tried putting the .ssh in /shares/.ssh/authorized_keys and in /etc/ssh//authorized_keys with a 700 and 640 for .ssh and authorized_keys respectively.

Any advice please?

New users are created by default with the same home /shares. You have two option:

  • Turn off the strictmodes in sshd_config. This will compromise the public keys as they are being shared.

  • Separate each user home to eg /shares/user (hint, use usermod or edit passwd file). Place both .ssh/authorised_keys in it with the correct permissions (chmod and chown).

1 Like

Nazar78 wrote:
New users are created by default with the same home /shares. You have two option:

  • Turn off the strictmodes in sshd_config. This will compromise the public keys as they are being shared.
  • Separate each user home to eg /shares/user (hint, use usermod or edit passwd file). Place both .ssh/authorised_keys in it with the correct permissions (chmod and chown).

Hi Nazar78, thanks for the reply!! It worked great!!

I like option two. For others that need the same thing. Here’s what I did to set up a user ‘savio’

  1. logged into mycloud as root and copied /etc/passwd to /etc/passwd-safe-in-case-we-screw-up :wink:

  2. logged into mycloud as root and went to /etc/passwd and changed /shares: to /shares/savio:  as this changes the home directory for user savio to /shares/savio vs. /shares

  3. logged into mycloud as savio and created a .ssh folder under /shares/savio (ie. mkdir /shares/savio/.ssh )

  4. logged into mycloud as savio and created the authorized_keys file (i.e. touch /shares/savio/authorized_keys)

  5. logged into mycloud as savio and run these 3 commands:
    chmod 777 /shares/savio 

chmod 777 /shares/savio/.ssh

chmod 777 /shares/savio/.ssh/authorized_keys

  1. from your local machine type the following:  

cat ~/.ssh/id_rsa.pub | ssh savio@ ‘cat >> /shares/savio/.ssh/authorized_keys’

  1. log into mycloud as savio and run these 3 commands:

chmod 700 /shares/savio

chmod 700 /shares/savio/.ssh

chmod 640 /shares/savio/.ssh/authorized_keys

  1. log out and try to log in as savio and it should all work
1 Like

No problem. Glad it helped…

I can’t recall but I believe before these steps, to even allow other users to ssh in WDMyCloud, we first need to modify the file ‘/etc/ssh/sshd_config’ to comment out ‘AllowUsers root’ then restart sshd.

Related to your step 1 & 2, I’ve posted few fixes not long ago about some bugs in firmware v3 which WD didn’t even fix in v4! In the fix, I included an optional patch to easily create user with its home path via WD’s webUI.

http://community.wd.com/t5/WD-My-Cloud/BUG-FIX-v03-04-01-230-New-user-s-share-with-password-being/m-p/742612

1 Like

Thanks a lot for this help, Nazar – I tried out option one, since there is only one user with ssh priveligies on my WD machine, and it worked like a charm. But could you say a little more about why it does not work to start with. Like the OP I put the public key in /shares/.ssh/authorized_keys with the right acess. The explanation I have read is:

“The option StrictModes specifies whether ssh should check user’s permissions in their home directory and rhosts files before accepting login. This option must always be set to yes because sometimes users may accidentally leave their directory or files world-writable.”

So is it the case that ‘/shares’ is not readable only for me which is the cause of it not working on strictmode? I did set the /shares/.ssh/ and /shares/.ssh/authorized_keys on 700 and 600, respectively.

In any case, thanks a bunch for solving the problem!

Hi SavioR. Thanks for your help
I found your post and followed instructions to give SSH access for a non root user using ssh keys. After several tries it didn’t work

Ssh root access is working fine with key files.

I changed home directory in /etc/passwd file for user and set chmod for directory and files exactly as you wrote.

I think maybe owner and group are not fine.

For example, I created a new user directly from shell and it works perfectly with key files.

Could you help me please?

Thank you so much.

Hi elbek

I had the same issue: worked with root but not with non root users created by the wd interface

in my case I found that it was because my non root users had their home directory under /shares (/shares/ in my case)

the permissions there have specific ACL grants which are inherited ( there is a plus sign when you do ls -l ; you can see more with getfacl )

I moved the home directoy to /home/ (created the folder and changed /etc/passwd) and it works fine from there

I guess it should be possible to turn the ACL permissions down on .ssh with setfacl to keep the homedir under shares … I did not need that