5

I am running CentOS 7 and need to mount an NFS share which is protected by credentials. I have read the nfs, mount, mount.nfs manuals and can't find the right options that work! I think the right options are 'user' and 'pass', but I've tried 'username' and 'password' and everything inbetween, but I get:

mount -t nfs -o user=root,pass=mypass lserver:/root /mnt/d0
mount.nfs: an incorrect mount option was specified

Can someone tell me the right syntax/options to make this work? (It really shouldn't be this hard)

4 Answers 4

17

Specifying username and password are options for cifs (samba), but not nfs. According to this RHEL Documentation:

NFS controls who can mount an exported file system based on the host making the mount request, not the user that actually uses the file system. Hosts must be given explicit rights to mount the exported file system. Access control is not possible for users, other than through file and directory permissions.

4
  • I missed that! But why is 'user' a valid parameter for NFS mounts?
    – TSG
    Feb 1, 2017 at 23:44
  • 1
    Where do you see that? There is no user option in man mount.nfs. Feb 1, 2017 at 23:51
  • When I try adding parameters, they all give invalid option errors, but the 'user' option does NOT generate an invalid option error
    – TSG
    Feb 2, 2017 at 1:06
  • 1
    See @Adonis' answer for why user= exists Apr 20, 2018 at 21:58
9
sudo mount -t nfs -O user=root,pass=mypass lserver:/root /mnt/d0

Notice that the 'O' is a capital letter.

1
  • 4
    it works for a SynologyNas local sever, thanks. Can you also tell me in this case, what would be the corresponding entry in the fstab? Aug 23, 2020 at 19:16
3

The user option is related to allow any users on your system allowed to mount the file system. See the "non-superuser mounts" of man mount

-6

This works under CentOS

mount.cifs //192.168.0.123/myshare /mnt/myshare -o user=myuser

(it asks for the password - you can add it on the commandline probably via pass=)

Run this by itself to see all the options:

mount.cifs

Usage: mount.cifs -o

Mount the remote target, specified as a UNC name, to a local directory.

Options: user= pass= dom=

Less commonly used options: credentials=,guest,perm,noperm,setuids,nosetuids,rw,ro, sep=,iocharset=,suid,nosuid,exec,noexec,serverino, mapchars,nomapchars,nolock,servernetbiosname= directio,nounix,cifsacl,sec=,sign,fsc

Options not needed for servers supporting CIFS Unix extensions (e.g. unneeded for mounts to most Samba versions): uid=,gid=,dir_mode=,file_mode=,sfu

Rarely used options: port=,rsize=,wsize=,unc=,ip=, dev,nodev,nouser_xattr,netbiosname=,hard,soft,intr, nointr,ignorecase,noposixpaths,noacl,prefixpath=,nobrl

Options are described in more detail in the manual page man 8 mount.cifs

To display the version number of the mount helper: mount.cifs -V

3
  • 4
    Your answer is totally valid but I was wondering why the downvotes. In fact the OP asked for NFS and not CIFS. That's probably the reason why your answer gets downvoted.
    – рüффп
    Mar 6, 2020 at 11:19
  • The OP asked for how to mount a NFS server that is protected by credentials. NFS exports are not protected by credentials, so ... something is wrong there, and the most likely scenarios are that it's not protected by credentials after all, or if it is it's not NFS -- and in the latter case, CIFS is the most likely case. So this answer could have been useful, though a bit more discussion about why it might be useful could be good too.
    – dougmc
    Mar 3, 2022 at 4:57
  • @dougmc NFS4 implements both unix auth and kerberos. Nov 28 at 2:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .