Question

Allow non root user to mount nfs share on Ubuntu

Hi, I am trying to mount nfs share on ubuntu without using “sudo” and getting below error. operation permitted for root only Can someone please help me to allow active directory domain user to mount nfs share in the server. Server is already configured with LDAP, I am able to login with my LDAP account on the server.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi, I want to use SFTP to store backup of different applications in our Infrastructure and have deployed Ubuntu server which has built in SFTP. Everything works fine if I use local account and local directory to store backups.I have used below link to configure it https://www.digitalocean.com/community/tutorials/how-to-enable-sftp-without-shell-access-on-ubuntu-16-04

Now, to store backup, I want to mount NFS or CIFS share.

  1. My initial challenge is that I cannot mount NFS/CIFS share without “Sudo”.
  2. If I use kerbros authentication at NFS server level then I am not able to mount the share, may be because I am using " Sudo"and NFS server does not authenticate that.I am not sure how to mount NFS share using LDAP credentials.
  3. I am able to mount CIFS share using Sudo mount -t CIFS -O LDAPUsername Password, where username is the user who has permission on that CIFS share.
  4. Now, as I have mounted the CIFS share on the server, I want to use LDAP account to copy data on CIFS share from application.

CIFS/NFS share - testbackup Directory on which CIFS/NFS share is mounted - /sftp/backup Path on which Application should store the backup - /sftp/backup/application1 (Similarly any other application is there then /sftp/backup/application 2 or 3 and so on) I tired changing the ownership of /sft/backup directory to ldap account using “sudo chown LDAPusername /sftp/backup” but it does not change the ownership and still shows root account as owner. I want LDAP user to have privileges on /sftp/backup directory and use that account to write backup under this directory remotely from the application. Apologies, if I have missed something as I do not have much experience in managing linux based systems and configuring this for the first time.

Hello,

Only the root user can specify options to the mount command, but you can still do this with only using the target from fstab as argument. You can edit /etc/fstab as root and set this there.

Then you can mount the nfs share manually in CLI

Once this is done you can use the following commands in order to auto mount the nfs on boot:

trail -1 /etc/mtab
trail -1 /etc/mtab >> /etc/fstab

If you can let me know what exactly you’re trying to achieve (e.g give me the exact directories and the options you want to use) I can further help you to set this.

Let me know how it goes.

Alex