Linux mount NFS with specific user

NFS v2 and v3 do not support uid/gid.

on Ubuntu man nfs


Adding this answer for posterity, as I ended up here with the same question.

Try this in /etc/export:

/var/www 192.168.56.1(rw,root_squash)

Then on the client, put this in /etc/fstab:

192.168.56.101:/var/www /home/gabor/Projects nfs defaults,user,noauto,relatime,rw 0 0

The user option will allow a non-root user to mount the volume. Adjust other options as needed.

Then on the client again, become the user you want to mount the volume as, and then mount the volume you added to /etc/fstab:

$ id
uid=1000(gabor) gid=1000(gabor) groups=1000(gabor)
$ mount /home/gabor/Projects
$

Make sure that the uid and/or gid are the same on the server. I'm not sure if the usernames can be different or not. Also make sure that the directory being exported on the server is writable by the user or group. See this blog post for additional info about setting up NFS in a similar manner.

Caution: This is an insecure configuration without authentication. Use NFS v4 with Kerberos for strong authentication.