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?
/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 currentfstab
, and copy-paste the commandUSER=UN mount /srv/mount_destination
and press Enter. (ReplacingUN
andmount_destination
as appropriate of course.)USER=UN mount /srv/mount_destination
replaces your original command. – Stephen Kitt Jun 08 '17 at 07:23mount: mount point /srv/mount_destination does not exist
. – Letokteren Jun 08 '17 at 07:40mount
. – Stephen Kitt Jun 08 '17 at 07:53yum install cifs-utils
, but now my current roadblock is:This program is not installed setuid root - "user" CIFS mounts not supported.
– Letokteren Jun 08 '17 at 08:57chmod 4755 /usr/sbin/mount.cifs
. Now I can dosudo -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 08 '17 at 09:07USER=
you actually set the enviroment variableUSER
. So according toman mount.cifs 8
, what I needed wasPASSWD=
. Thank you for your time! – Letokteren Jun 08 '17 at 09:39