Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I heard that NFS share via SSH tunnel is impossible on Mac OS X:

I have been trying 2 days to make it, but I failed. Is it really impossible? Or what should I have to do?

share|improve this question

In Snow Leopard, the mountport and port options appear to be supported, but if the manual is lying (not altogether unusual, as Apple often just copies the FreeBSD manuals) then you won't be able to do it. ssh doesn't know how to tunnel either Sun RPC or UDP; you would have to add both of those to ssh and the remote sshd, and Sun RPC in particular will be difficult to say the least.

(strings /sbin/mount_nfs seems to indicate that those options are in fact supported.)

share|improve this answer
Oh there is ,port=%d ,mountport=%d. I'm currently fighting with mount_nfs: bad MNT RPC: RPC: Authentication error; why = Client credential too weak\n... – Eonil Mar 9 '11 at 10:14
Wow! I got succeeded! I'll post an answer as soon as! – Eonil Mar 9 '11 at 10:24

I got succeeded! Mostly I followed the tutorial which I linked in the question. However the OS used in the question is CentOS different with FreeBSD.

Server side configurations

First just initiate a FreeBSD box with SSH and NFS. I used fresh new installation in VM. I made a directory to share ttt.

mkdir /ttt
chmod 777 /ttt

And exported it via NFS by adding this line to /etc/exports

/ttt -alldirs

And add this line to /etc/rc.conf


All done. No more server-side setting job required.

The flag -n enables non-root mount. It feels some security issue but however this is most simple way. I'll post a new question about security of this flag.

Client side configurations

And establish 2 SSH tunnels.

ssh -2 -N -L 5000:localhost:2049 eonil@test.local
ssh -2 -N -L 5001:localhost:1019 eonil@test.local

test.local is the address of the FreeBSD box. And the localhost in the command means the FreeBSD box itself. (This will be evaluated in server-side) You have to open multiple terminal window because I didn't set -f to keep SSH foreground. Just for checkup.

The port number 2049 is default port for NFS server, and 1019 is default port of mountd. You have to always specify this port numbers because NFS has no official default port number. (That's just de-facto standard :) I don't know about mountd. 2 days taken getting know the fact that I have to specify these damn port numbers.

And in other terminal, mount via SSH tunnels.

mount_nfs -v -o port=5000,mountport=5001,tcp localhost:/ttt /tttm 

I used -v for log messages. I have /tttm folder on my Mac. These messages,

mount localhost:/ttt on /tttm
mount flags: 0x0 tcp,port=5000,mountport=5001, fh 28 ea58774dc6ccd11b0c000000016a00003300c1da0000000000000000
NFS options: 0x3004200 fg,retrycnt=1,vers=3,sec=sys (1)

printed, and shared volume appeared at the location /tttm!

My method may have many security issues. Such as chmod 777 or -n switches look insecure. If you know better configuration, please let me know. Thank you.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.