# NFS exports

NFS is the file sharing of Unix and Linux, also offered by most NAS and storage systems. An item of a [VFS](VFS.md) can point at a folder of an NFS server. The server speaks NFS itself: nothing is mounted on the machine, and no rights of the system's administrator are needed for it.

The server speaks **NFS version 4.1**. A file server that offers only version 3 cannot be reached this way: mount it on the machine and use it as a [local folder](VFS-Local.md).

![An NFS item](VFS-NFS/dialog.png)

## The address

`NFS://nas01.example.com/export/projects/` : the server and the path. In NFS 4 a server's exports hang in one tree, so the path is simply a path. The address of the server alone, `NFS://nas01.example.com/`, lists what it exports.

## Who the server is, for the NFS server

NFS does not log in with a name and a password. The field **Security** decides how the server says who it is:

| Security | Means |
|---|---|
| **AUTH_SYS (uid/gid)** | the server states a numeric user and group, and the NFS server believes it. Nothing is proven. |
| **AUTH_NONE (anonymous)** | the server says nothing; the NFS server treats it as "nobody" |
| **Kerberos (krb5)** | the server proves who it is with Kerberos |
| **Kerberos + integrity (krb5i)** | and every message is protected against changes |
| **Kerberos + privacy (krb5p)** | and everything is encrypted |

### AUTH_SYS

| Field | What it is |
|---|---|
| **uid**, **gid** | the numbers of the user and the group the server acts as. Files it makes belong to them, and it may read what they may read. |
| **Supplementary gids** | further groups, as numbers |
| **User name**, **Password** | a number in **User name** is taken as the uid, a number in **Password** as the gid, when the fields above are empty |
| **Source from a privileged port** | "needed for a Linux export using the default "secure" option". The connection then comes from a port below 1024, which a Linux NFS server demands unless the export says `insecure`. On Linux and macOS the CrushMFT server must be allowed to use such ports. |

Because AUTH_SYS proves nothing, an NFS server protects itself by the list of machines it exports to. Add the CrushMFT server's address to that list, and nothing else that does not need it.

### Kerberos

| Field | What it is |
|---|---|
| the Kerberos credential | "The name of an entry on the Kerberos panel in the server's Preferences." The login is made with that entry's keytab, as its principal: see [Kerberos](Prefs-Kerberos.md). |
| the service principal | "Only when the server's principal is not nfs/ followed by the host in the URL." |

The item itself holds no key and no password: who the server is, is decided in the Preferences, by an administrator of the server.

Use **krb5p** when the files travel over a network you do not control.

## One identity for everybody

Every user of CrushMFT who uses the item acts on the NFS server as the same uid, or the same principal. Who may do what is decided by the [permissions](VFS-Permissions.md) of the item in CrushMFT, not by the NFS server. Choose a uid that has the rights the most privileged of these users needs, and narrow down in CrushMFT.

The options every type has are on [Advanced options of a VFS item](VFS-Advanced.md).

## Ports

NFS 4.1 uses TCP port 2049 on the file server, and nothing else: no port mapper, no mount service.

## When it does not work

| What you see | Usually |
|---|---|
| access denied at once | the CrushMFT server's address is not in the export's list; or the export wants a privileged port |
| the folder lists, files cannot be read or written | the uid and gid have no rights on them; or the export squashes the user to "nobody" |
| everything is refused as root | uid 0 is turned into "nobody" by the usual `root_squash`: use an ordinary uid |
| a time-out | port 2049 closed on the way; or the server offers only NFS 3 |
| Kerberos fails | the entry on the Kerberos panel, the clocks of the machines, or the service principal |
