Tunnel webdav over ssh and bypass proxy

Sep 24, '04 10:04:00AM

Contributed by: ikno

SSL support for webdav is not available on Mac OS X, but it is possible to tunnel webdav over ssh. One can set up the tunnel as follows:

$ ssh -fN -L8080:localhost:80 webdavserver
$ mkdir /Volumes/mnt
$ mount_webdav localhost:8080/Users /Volumes/mnt
Where webdavserver is the hostname of your webdav server, and you want to access the /Users folder on your local machine via the path /Volumes/mnt. You must have an account on webdavserver.

Read the rest for the post-use cleanup instructions, and a proxy bypass hint...

When you are done, clean up as follows (comments noted with #, commands with $):

# unmount the webdav mount
$ umount /Volumes/mnt

# remove the directory
$ rmdir /Volumes/mnt

# assign the variable named pid the process id of the ssh
# tunnel process. do this by running the ps command and 
# use the awk program to filter out the awk process and
# to print the process id of the ssh process as identified
# by the string ssh -fN -L ...
$ pid=`ps -x|awk "/awk/{ next; } \
     /ssh -fN -L$8080:localhost:80 webdavserver/ {print \\$1; }"`

# if the value in pid is greater than 2, the kill that process
# It's value should really only be 0 or some other number much
# greater than 1. This just safe guards us from killing the Darwin
# init process.
$ [ ${pid:-0} -gt 2 ] && kill $pid
But what if your Network Preferences are configured with a proxy setting? Well, one would think you could just add localhost to the proxy bypass settings list. However, due to a bug in mount_webdav, the exception localhost will be ignored.

The workaround is to add ocalhost to the proxy bypass list. Yes, that's localhost with the leading l dropped. In general, mount_webdav will ignore any exception host that is identical in length to the actual hostname specified on the mount_webdav command line. The workaround is to specify the exception hostname with the leading character dropped.

Comments (0)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040920100413622