I couldn’t find an exact example of my implementation to mount an AFP share over SSH on my Mac, especially when the share has spaces in the shared folder name. I had seen a couple posts on forums that mention url-encoding the spaces, but since I’m on the command line, I often think of escaping spaces with a backslash. Well it turns out that url-encoding a space with
%20 makes it work and here’s a little script I run to mount remote AFP shares:
umount "/Volumes/Share With Spaces In Folder Name" # unmount any stale shares rmdir "/Volumes/Share With Spaces In Folder Name" # remove any stale sharepoints pkill ssh -NfL 5548:127.0.0.1:548 email@example.com # kill any ssh sessions with specific port redirections ssh -NfL 5548:127.0.0.1:548 firstname.lastname@example.org # ssh and port redirect into your remote system mkdir "/Volumes/Share With Spaces In Folder Name" # create a new sharepoint mount_afp afp://username:password@localhost:5548/Share%20With%20Spaces%20In%20Folder%20Name /Volumes/Share\ With\ Spaces\ In\ Folder\ Name
With this method I realize that my password is in the clear on the command, but since it’s mounting on my system to a port that is tunneling ssh, the password is encrypted in the transmission request so therefor not technically transmitted in the clear across the internet.