Scooby-2
October 6th, 2014, 09:40 PM
The WD My Cloud supports NFS by default and the server itself needs only one configuration file to be changed in order to work correctly with Linux clients running NFS.
This how-to shows you what you need to do to add a user to the My Cloud, add a private share to the server and enable access to it via NFS. I have tried to make it as easy as possible for people who are not comfortable editing files from the command line by using commands which can (with one or two exceptions) be copied and pasted.
Edit 2 Nov 2014: This tutorial is applicable regardless of the client OS, be it Windows, OSX, Linux, Solaris, AIX, Haiku or whatever. However you need to know how to access the WD My Cloud UI (for which I recommend reading the WD documentation) and how to run a terminal session from that OS.
Edit 3 May 2015: Changed some of the quotes text to code, as spurious spaces are added by the forum software.
Please note that following these instructions will entail running commands as root on the WD My Cloud. Be warned that it is VERY easy to brick your server by running commands as root. I accept no responsibility for anyone who manages to brick their system(s) following this guide.
1. If the user you want to use has already been defined, skip to step 3. To add a new user to the server use the the UI. After logging in, click Users (1 in the screen print), then the Add User button (2):
http://i1244.photobucket.com/albums/gg567/Scooby269/1_zpsa7b22976.jpg
2. In the Add User box, enter the desired user name. I suggest using the same user name on the Linux system that you want to be able to connect to the server. This is the only required field, the others may be left blank. However, for security, you may wish to assign a password (this would be used if you were to connect using SMB). Type in the required user ID - in my example I am adding a user called janm. Click the Save button.
http://i1244.photobucket.com/albums/gg567/Scooby269/2_zps7eb18d62.jpg
3. If the share you want to use already exists, skip to step 5. Otherwise click on Shares (3 in the screen print below) the Add Folder button (4).
http://i1244.photobucket.com/albums/gg567/Scooby269/3_zps00aaf77b.jpg
4. Add the folder name that you wish the user to see when they look for their private folder in File Manager. This is the only required field. Click Save.
http://i1244.photobucket.com/albums/gg567/Scooby269/4_zps2546c234.jpg
5. Turn off Public Access and enable full access for the new user as shown below.
http://i1244.photobucket.com/albums/gg567/Scooby269/5_zps47c742f6.jpg
6. Turn on SSH by clicking on Settings (5), Network (6) and then SSH (7). Set it to on (if it isn't already).
http://i1244.photobucket.com/albums/gg567/Scooby269/6_zps89338c08.jpg
7. To log in to the server via SSH, from the client open a terminal window and type
ssh root@{IP_OF_YOUR_SERVER}If you see something like this:
The authenticity of host 'nas (xxx.xxx.xxx.xxx)' can't be established.RSA key fingerprint is 12:34:56:78:90:AB:CD:EF:00:11:22:33:44:55:66:77.
Are you sure you want to continue connecting (yes/no)? Answer yes. You are getting this message because it the first time you are connecting via SSH. You should then see
Warning: Permanently added 'nas,xxx.xxx.xxx.xxx' (RSA) to the list of known hosts. and you will be prompted for the root password of the NAS server. Type your root password, or if you haven't ever changed it, type welc0me. If you are logged on using the default password CHANGE IT NOW by typing
passwd
and enter a new one.
8. We now need to modify the file responsible for managing the exports on the server. There are two ways to do this - method one is best for inexperienced users, where the file is created on the client using your favourite text editor. Method two is fine if you are comfortable running commands as root on the server (see warning above).
Method 1. Log in to the server and run the following commands to back up and write protect the original file:
cd /etc
cp exports exports.orig
This copies your original file in case you mess up and need to restore it.
If you are asked if you want to overwrite exports.orig answer no. It probably means you are running through this for the second time and answering yes will overwrite your original file. Seek advice...
chmod 400 exports.orig
This command makes the copy read-only, so you will get the prompted before it will be overwritten (see above)/
On your Linux client, open your favourite text editor and create a file named exports with the following text:
# Use nobody user (uid 65534) for nfs guest. This is restricted from private
# shares by ACLs.
#
/nfs/Public *(rw,all_squash,sync,no_subtree_check,insecure,cro ssmnt,anonuid=65534,anongid=1000)
/nfs/janm *(rw,no_all_squash,sync,no_subtree_check,insecure, crossmnt,anonuid=65534,anongid=1000)
# Replace janm with the user name you created in step 2.
Save the file in your home directory.
In the terminal window, log out of the server so you are working on your client and type the following:
cd
and then
rcp exports root@xxx.xxx.xxx.xxx:/etc/
(# Replace xxx.xxx.xxx.xxx with your NAS server's IP address)
The rcp command stands for remote copy, and allows files to be transferred over the network via SSH.
Go to step 9.
Method 2. Log in to the NAS server via SSH. Copy and paste the following lines (paste is available from the menu in terminal) ONE AT A TIME .
cd /etc
cp exports exports.orig
If you are asked if you want to overwrite exports.orig answer no. It probably means you are running through this for the second time and answering yes will overwrite your original file. Use method 1 instead.
chmod 400 exports.orig
sed -i 's:^/nfs:/nfs/Public:' exports
newid=janm
# INSTEAD OF janm TYPE THE NEW USERNAME YOU CHOSE ABOVE IN STEP 2 ABOVE.
echo "/nfs/$newid *(rw,no_all_squash,sync,no_subtree_check,insecure, crossmnt,anonuid=65534,anongid=1000)" >> exports
What we are doing here is:
Changing directory to /etc
Copying the exports file to one called exports.orig
Making the copy read only, so it will not be overwritten without a prompt.
The next line appends /Public to the line which starts /nfs. This is so the the Public directory will be available to everyone.
The newid.... line just sets a variable which is used below.
This line echoes the text and appends it to the exports file, adding /nfs/{newid}. The bunch of text after that makes it private to the new user.
Here it is in action:
http://i1244.photobucket.com/albums/gg567/Scooby269/7_zps08aa78a8.jpg
9. From the terminal logged on to the server, to view the updated contents of the exports file type
cat /etc/exports
and you should see this, except the username on the last line should match what you entered:
http://i1244.photobucket.com/albums/gg567/Scooby269/8_zps5ea613fb.jpg
I am only permitted to use 8 images per post, so this post is continued here (http://ubuntuforums.org/showthread.php?t=2247242).
Second edit for clarification and add the option to create the new exports file locally, then rcp it to the server.
Third edit to replace a photo with a typo on the screen and to add a description of what the commands do.
Fourth edit to advise that this tutorial is not OS dependent but users need to know how to access the NAS UI and also how to start ssh in a terminal session.
This how-to shows you what you need to do to add a user to the My Cloud, add a private share to the server and enable access to it via NFS. I have tried to make it as easy as possible for people who are not comfortable editing files from the command line by using commands which can (with one or two exceptions) be copied and pasted.
Edit 2 Nov 2014: This tutorial is applicable regardless of the client OS, be it Windows, OSX, Linux, Solaris, AIX, Haiku or whatever. However you need to know how to access the WD My Cloud UI (for which I recommend reading the WD documentation) and how to run a terminal session from that OS.
Edit 3 May 2015: Changed some of the quotes text to code, as spurious spaces are added by the forum software.
Please note that following these instructions will entail running commands as root on the WD My Cloud. Be warned that it is VERY easy to brick your server by running commands as root. I accept no responsibility for anyone who manages to brick their system(s) following this guide.
1. If the user you want to use has already been defined, skip to step 3. To add a new user to the server use the the UI. After logging in, click Users (1 in the screen print), then the Add User button (2):
http://i1244.photobucket.com/albums/gg567/Scooby269/1_zpsa7b22976.jpg
2. In the Add User box, enter the desired user name. I suggest using the same user name on the Linux system that you want to be able to connect to the server. This is the only required field, the others may be left blank. However, for security, you may wish to assign a password (this would be used if you were to connect using SMB). Type in the required user ID - in my example I am adding a user called janm. Click the Save button.
http://i1244.photobucket.com/albums/gg567/Scooby269/2_zps7eb18d62.jpg
3. If the share you want to use already exists, skip to step 5. Otherwise click on Shares (3 in the screen print below) the Add Folder button (4).
http://i1244.photobucket.com/albums/gg567/Scooby269/3_zps00aaf77b.jpg
4. Add the folder name that you wish the user to see when they look for their private folder in File Manager. This is the only required field. Click Save.
http://i1244.photobucket.com/albums/gg567/Scooby269/4_zps2546c234.jpg
5. Turn off Public Access and enable full access for the new user as shown below.
http://i1244.photobucket.com/albums/gg567/Scooby269/5_zps47c742f6.jpg
6. Turn on SSH by clicking on Settings (5), Network (6) and then SSH (7). Set it to on (if it isn't already).
http://i1244.photobucket.com/albums/gg567/Scooby269/6_zps89338c08.jpg
7. To log in to the server via SSH, from the client open a terminal window and type
ssh root@{IP_OF_YOUR_SERVER}If you see something like this:
The authenticity of host 'nas (xxx.xxx.xxx.xxx)' can't be established.RSA key fingerprint is 12:34:56:78:90:AB:CD:EF:00:11:22:33:44:55:66:77.
Are you sure you want to continue connecting (yes/no)? Answer yes. You are getting this message because it the first time you are connecting via SSH. You should then see
Warning: Permanently added 'nas,xxx.xxx.xxx.xxx' (RSA) to the list of known hosts. and you will be prompted for the root password of the NAS server. Type your root password, or if you haven't ever changed it, type welc0me. If you are logged on using the default password CHANGE IT NOW by typing
passwd
and enter a new one.
8. We now need to modify the file responsible for managing the exports on the server. There are two ways to do this - method one is best for inexperienced users, where the file is created on the client using your favourite text editor. Method two is fine if you are comfortable running commands as root on the server (see warning above).
Method 1. Log in to the server and run the following commands to back up and write protect the original file:
cd /etc
cp exports exports.orig
This copies your original file in case you mess up and need to restore it.
If you are asked if you want to overwrite exports.orig answer no. It probably means you are running through this for the second time and answering yes will overwrite your original file. Seek advice...
chmod 400 exports.orig
This command makes the copy read-only, so you will get the prompted before it will be overwritten (see above)/
On your Linux client, open your favourite text editor and create a file named exports with the following text:
# Use nobody user (uid 65534) for nfs guest. This is restricted from private
# shares by ACLs.
#
/nfs/Public *(rw,all_squash,sync,no_subtree_check,insecure,cro ssmnt,anonuid=65534,anongid=1000)
/nfs/janm *(rw,no_all_squash,sync,no_subtree_check,insecure, crossmnt,anonuid=65534,anongid=1000)
# Replace janm with the user name you created in step 2.
Save the file in your home directory.
In the terminal window, log out of the server so you are working on your client and type the following:
cd
and then
rcp exports root@xxx.xxx.xxx.xxx:/etc/
(# Replace xxx.xxx.xxx.xxx with your NAS server's IP address)
The rcp command stands for remote copy, and allows files to be transferred over the network via SSH.
Go to step 9.
Method 2. Log in to the NAS server via SSH. Copy and paste the following lines (paste is available from the menu in terminal) ONE AT A TIME .
cd /etc
cp exports exports.orig
If you are asked if you want to overwrite exports.orig answer no. It probably means you are running through this for the second time and answering yes will overwrite your original file. Use method 1 instead.
chmod 400 exports.orig
sed -i 's:^/nfs:/nfs/Public:' exports
newid=janm
# INSTEAD OF janm TYPE THE NEW USERNAME YOU CHOSE ABOVE IN STEP 2 ABOVE.
echo "/nfs/$newid *(rw,no_all_squash,sync,no_subtree_check,insecure, crossmnt,anonuid=65534,anongid=1000)" >> exports
What we are doing here is:
Changing directory to /etc
Copying the exports file to one called exports.orig
Making the copy read only, so it will not be overwritten without a prompt.
The next line appends /Public to the line which starts /nfs. This is so the the Public directory will be available to everyone.
The newid.... line just sets a variable which is used below.
This line echoes the text and appends it to the exports file, adding /nfs/{newid}. The bunch of text after that makes it private to the new user.
Here it is in action:
http://i1244.photobucket.com/albums/gg567/Scooby269/7_zps08aa78a8.jpg
9. From the terminal logged on to the server, to view the updated contents of the exports file type
cat /etc/exports
and you should see this, except the username on the last line should match what you entered:
http://i1244.photobucket.com/albums/gg567/Scooby269/8_zps5ea613fb.jpg
I am only permitted to use 8 images per post, so this post is continued here (http://ubuntuforums.org/showthread.php?t=2247242).
Second edit for clarification and add the option to create the new exports file locally, then rcp it to the server.
Third edit to replace a photo with a typo on the screen and to add a description of what the commands do.
Fourth edit to advise that this tutorial is not OS dependent but users need to know how to access the NAS UI and also how to start ssh in a terminal session.