2

I am trying to use NFS over an SSH tunnel to share a directory. I explicitly specify TCP port 2049, but there is apparently more I need to do. It seems to have something to do with the "portmapper" service, with which I am not familiar. Is it possible to operate NFS without it using the portmapper service? As I said, I explicitly specify what port I want used.

As I demonstrate below, if I have the client connect to the share directly, everything works fine. However, if I have the client try to connect to the share via an SSH tunnel, it does not work.

How may I solve this problem?

Server (my-NFS-Server)

root@my-NFS-Server:~# ls -l /consolidate
total 1
-rw-rw-r-- 1 root automation 0 Dec 19 13:33 thisFileExistsOnlyInShareOnServer

root@my-NFS-Server:~# cat /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/zvol/rpool/swap none swap sw 0 0
proc /proc proc defaults 0 0
/consolidate /export/consolidate none bind 0 0

root@my-NFS-Server:~# cat /etc/exportfs
/export *(sync,rw,wdelay,no_root_squash,no_subtree_check,sec=sys,secure,no_all_squash,fsid=0)
/export/consolidate *(sync,rw,wdelay,no_root_squash,no_subtree_check,sec=sys,secure,no_all_squash)

root@my-NFS-Server:~# grep NEED_SVCGSSD /etc/default/nfs-kernel-server
NEED_SVCGSSD=no

root@my-NFS-Server:~# service nfs-kernel-server restart

root@my-NFS-Server:~# ssh -N -R localhost:2049:localhost:2049 root@my-NFS-Client

Client (my-NFS-Client)

root@my-NFS-Client-1:~# ls -l /consolidate
total 0

root@my-NFS-Client-1:~# mount -v -t nfs4 -o proto=tcp,port=2049 my-NFS-Server:/consolidate /consolidate
mount.nfs4: timeout set for Wed Dec 20 12:51:49 2017
mount.nfs4: trying text-based options 'proto=tcp,port=2049,vers=4.2,addr=my-NFS-Server,clientaddr=my-FNS-Client'

root@my-NFS-Client-1:~# ls -l /consolidate
total 1
-rw-rw-r-- 1 root automation 0 Dec 19 13:33 thisFileExistsOnlyInShareOnServer

root@my-NFS-Client-1:~# umount /consolidate

root@my-NFS-Client-1:~# ls -l /consolidate
total 0

root@my-NFS-Client-1:~# mount -v -t nfs4 -o proto=tcp,port=2049 localhost:/consolidate /consolidate
mount.nfs4: timeout set for Wed Dec 20 12:52:16 2017
mount.nfs4: trying text-based options 'proto=tcp,port=2049,vers=4.2,addr=127.0.0.1,clientaddr=127.0.0.1'
mount.nfs4: mount(2): Operation not permitted
mount.nfs4: trying text-based options 'proto=tcp,port=2049,addr=127.0.0.1'
mount.nfs4: prog 100005, trying vers=3, prot=6
mount.nfs4: portmap query failed: RPC: Program not registered
mount.nfs4: requested NFS version or transport protocol is not supported

root@my-NFS-Client-1:~# ls -l /consolidate
total 0

1 Answer 1

0

I managed to get NFS over SSH working by doing the following:

  • service stop portmap to free up local TCP port 111 (portmapper)
    • This seems really bad to me, but since I was on a toy VM, I did it anyway. No doubt it will break something...
  • ssh user@remote -L 111:nfs-server-name:111
  • rpcinfo -p localhost and find the ports used by mountd, was 300 in my case
  • ssh user@remote -L 300:nfs-server-name:300
  • mount -v -t nfs -o proto=tcp,vers=3,nolock localhost:/path /mountpoint

You must log in to answer this question.

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