I have a mount command which with the use of -t cifs mounts a remote folder (for example \\remote_ip_address\folder) to a local folder (for example /srv/mount_destination).

So the whole command looks like this:

mount -t cifs -o ro,username=UN,password=PWD '\\remote_ip_address\folder' /srv/mount_destination

However I receive the following error:

mount: only root can use "--options" option

My problem is that this command has to be run by user, however user does not have and can not have sudo priveledges, so using the command with sudo is out of the question. Another road block is that the remote folder has to be mounted under a folder in /srv, thus using other folders like /media is not an option either.

I've tried to add the following line to /etc/fstab, restarted the system but without any positive effect:

//remote_ip_address/folder /srv/mount_destination cifs noauto,user 0 0

Is there something I did wrong or is there anything I'm still missing?


Given the line you’ve added to /etc/fstab, the following should work:

USER=UN mount /srv/mount_destination

(replacing UN with the appropriate value). This will use the file system, target and options specified in /etc/fstab, the username stored in the USER environment variable, and prompt for a password. If you want the ro option, you should add that to /etc/fstab too (noauto,user,ro).

The -o limitation (only root can specify it) is in place to protect the system: the administrator can set up whatever options are necessary, either directly using -o or using /etc/fstab; users can only cause user-controllable file systems to be mounted or unmounted, without specifying options, because file system options allow a number of hostile scenarios. As a result, some file systems support other ways of setting certain options, such as the USER environment variable used above with CIFS.

mount.cifs (which is used by mount -t cifs) supports a number of other settings which may be relevant. The multiuser option in particular can be very useful.

  • Thank you for your explanation, but I feel like I'm still missing something. When you say, "the following should work", I'm not sure what I'm supposed to do. May I ask you to rewrite my original command and fstab configuration in a way you think it should work?
    – Letokteren
    Jun 8 '17 at 7:16
  • I mean, given the line you’ve added to /etc/fstab (which doesn’t need changing), if you type exactly the command I wrote above, it should work, prompting you for the password. Put differently, keep your current fstab, and copy-paste the command USER=UN mount /srv/mount_destination and press Enter. (Replacing UN and mount_destination as appropriate of course.) USER=UN mount /srv/mount_destination replaces your original command. Jun 8 '17 at 7:23
  • I left the fstab as it is then, and run the command as you've asked, even restarted the machine itself, but now I get: mount: mount point /srv/mount_destination does not exist.
    – Letokteren
    Jun 8 '17 at 7:40
  • 1
    Yes, this was, in fact, a problem. After that, I had to do yum install cifs-utils, but now my current roadblock is: This program is not installed setuid root - "user" CIFS mounts not supported.
    – Letokteren
    Jun 8 '17 at 8:57
  • 1
    Please, disregard my previous statement. I've found a forum, where someone suggested the following: chmod 4755 /usr/sbin/mount.cifs . Now I can do sudo -u someuser USER=login_user_to_remote PASS=PWD mount /srv/some_destination, and it works. I only have one remaining question. It still asks me for a password, however I would like to add the command to a cron job, so I have to add the password as some sort of parameter.
    – Letokteren
    Jun 8 '17 at 9:07
  1. Using sudoer:

a. edit your /etc/fstab file:

vi /etc/fstab
# To allow <add_your_UN> user to access msshare.
//remote_ip_address/folder /srv/mount_destination cifs vers=3.0,username=<add_your_UN>,noauto,user 0 0

can’t use -o option, it’s for admins! as per @Stephen Kitt explaination above.

b. change permisions for /usr/sbin/mount.cifs from -rwxr-xr-xto -rwsr-xr-x using (as per @Letokteren above)

chmod 4755 /usr/sbin/mount.cifs
  1. Using <add_your_UN>:

a. create you folder mkdir -p /srv/mount_destination

b. Mount you drive!

USER=<add_your_UN> mount /srv/mount_destination

it prompts for your network password and boom!

Password for <add_your_UN>@//remote_ip_address/folder:  ************

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.