Happy Friday!
all posts

Slowdowns using VPN and Mac OS X?

Published on Feb 13, 2013

Chris Vandebroek

Are you suffering from slow directory listings and/or file transfers using Apple's Finder while connected through VPN? You're at the right place, read on!

Some Background First

Our lovely file-server (Ubuntu Linux) in the office handles small, big and huge files, just about everything we need to work with and share. About 5 people are connected against the box transfering files back and forth. We use SMB shares as Samba is/was easy to setup and maintain. It felt like a natural choice. (We also tried Netatalk aka AFP, but it didn't work very well)

As we work remotely regularly we also installed a VPN service to access files from everywhere outside the office securely. Nobody is forced to be in the office, we might also work from home or whatever place we feel appropriate to get our things done.

From day one directory listings and file transfers have been slow like hell. In fact it was so slow, that two of my colleagues and myself started research and began our experiments on different VPN services, e.g. PPTP, IPSec, L2TP over IPSec, OpenVPN. You get to read about differences with those services, e.g. speed, security and what not – just forget about all that, except for the security thing, it didn't change anything on speed. The VPN server was not the issue!

An Incidental Discovery

We can login to the box via SSH for maintenance reasons. One day I needed to sync files between two locations, so I connected to the file-server using Forklift. Surprisingly it was fast and convenient, not the usual slow crappy connection... Would SSH be the solution? Let's give it a try!

The Solution

I installed SSHFS (find the sshfs package on github) on my Mac, went home in the afternoon to test the thing... It didn't change anything, same slowdowns. What's the difference then? Why is connecting through SFTP with Forklift so much faster then SSHFS? I started to explore options with SSHFS and MacFUSE and BOOM (in fact it felt like days and hours) there was my solution!

Mount your share using the following command and options:

sshfs USER@DEST:REMOTE_PATH LOCAL_PATH -oauto_cache,reconnect,defer_permissions,noappledouble,volname=VOLNAME

The option-flag that did the trick is noappledouble. It prevents Finder from reading all those .DS_Store, ._*-whatever files that causes the slowdowns. Using that option does not only make AppleDotFiles invisble to Finder it simply disables the usage completely.

To make the long story short: I became a huge fan of SSHFS and do really enjoy remote work now. The connection has never been faster.

This solution has been tested using OS X 10.7. and 10.8.

[EDIT] - Additional Options To Fix Encoding Issues

While being happy with the solution I encoutered some issues with encodings. I was unable to use any data with umlauts. To make Finder work correctly with umlauts add those additional options to your mount command:

modules=iconv,to_code=UTF-8-MAC