MacNN Forums (
-   Applications (
-   -   Mounting Volume over SSH/sftp applications (

DeuceOfHearts Sep 3, 2006 11:59 PM
Mounting Volume over SSH/sftp applications
I can't seem to determine how to do this.

I've got a remote server that only supports SSH and FTP access. I want to set it up so that I can edit text files directly on that server. Normally, I would mount a network drive over AFP. I've worked in a situation where the network drive was mounted over other protocols, but I do not know how to do this.

I attempted to use Connect To Server (Command+K) to connect, but discovered that FTP through Finder only allows Read access, and no write access.

How can I mount these remote files as a volume of some sort?
CharlesS Sep 4, 2006 12:29 AM
You can't do this with the Finder, but TextWrangler will let you directly edit text files on an SFTP (SSH) server.
DeuceOfHearts Sep 4, 2006 12:34 AM
Quote, Originally Posted by CharlesS
You can't do this with the Finder, but TextWrangler will let you directly edit text files on an SFTP (SSH) server.

Yes, I've found a number of solutions such as this (I happen to be using TextWrangler right now... though I think that if jEdit was built more for MacOSX I'd prefer it). I'd like something more elegant, however. I'd like to use the editor(s) of my choice on the files, and have this integration at a lower level. I recognize that there's no way to do it through finder, but what about a way to do it through the Terminal at a more basic level? I tried taking a look at the mount command, but I don't know quite enough about filesystems to figure it out.
CharlesS Sep 4, 2006 12:37 AM
OS X doesn't include an SFTP file system driver, so there's no way that I know of to do this except to use a text editor that does SFTP.
DeuceOfHearts Sep 4, 2006 12:42 AM
Thanks, Charles... guess I'll work with the texteditors directly then.
Simon Sep 4, 2006 04:13 AM
No, no, no.

SSH is more than enough. You can do AFP through SSH tunneling and then you can mount your drives, copy, move, etc. just as you otherwise would.

In your ~/.ssh/config add something like

Host remoteMac
User yourName
# afp
LocalForward 9548

Whenever you want to mount the volume, open an ssh connection like


ssh yourName@remoteMac
Then, in the finder, open the 'Connect to Server...' dialog and instead of just using "remoteMac" the way you used to, you enter


Basically, you just tunnel all AFP traffic (port 548) over ssh. The tunnel takes all traffic on your local port 9548 and relays it to the remote AFP port. Simple but useful.
Tsilou B. Sep 4, 2006 04:54 AM
Simon's solution is great, however, it will only work if the remote computer is a Mac with File Sharing turned on.
If it isn't, try an SFTP client like Transmit (trial version available). It lets you browse your remote files and edit any file with any editor. It does that by downloading the file to a temporary directory, opening it with the application of your choice, and everytime you save changes to that file, it automatically uploads the file back to the (S)FTP server. It works absolutely transparently, so it really appears as if you could directly edit files on the server.
Simon Sep 4, 2006 05:45 AM
Darn, I thought the OP had written he can use AFP on the remote machine. Need more coffee. ;)

If only FTP is available, the ssh tunneling method will still work however. You just have to use the FTP port 20 instead of the AFP port 548.

Actually, you could also just forget ftp altogether and use scp (which uses an ssh connection) instead. You can get the files with scp, modify them locally and send them back with scp again. Check out man scp. It's simple and fast.
OreoCookie Sep 4, 2006 06:01 AM
It seems like this thread is moving towards software … moving

There are numerous free sftp-capable applications (fugu, CaptainFTP), so you don't even have to pay for them. Simon's suggestion sounds great, I need to give that a try with my parents' Mac ;)

Edit: I've decided to change the title accordingly.
Simon Sep 4, 2006 09:07 AM
FTP or AFP over ssh works great with the method I described. I use it every day because my lab has closed all ports other than 22 for incoming traffic. Whenever I want to get onto my work Macs from home, that's the easiest way to get it done. And you get secure encrypted data transmission for free too. ;)
OreoCookie Sep 4, 2006 11:06 AM
Sure, that's great to know. I knew that it was technologically feasible, but I have never really looked into it. Now that I know it's so trivial, I will definitely give it a shot.
Geobunny Apr 19, 2007 04:54 PM
Sorry to dredge up an old discussion but I was just looking for the same thing and came across this thread as well as a proper solution to the original poster's request. Have a look at sshFS - it does exactly what you're looking for, is free and open source :)

Basically, download and install (the installer prompts you to restart but if you know how to load a kernel extension there's no need to).
In the terminal:
Create a new directory
mkdir -p ~/sshfs/XYZ

Mount the remote home directory over ssh:
/Applications/sshfs/bin/mount_sshfs ~/sshfs/XYZ

You can call the mountpoint anything you like so long as it's the same in both commands.

Unmount the volume in the usual command-line fasion:
umount ~/ssh/XYZ
besson3c Apr 19, 2007 05:00 PM
Here is an article I wrote about using SSHfs in OS X:

NetMusician Labs Blog Archive FUSE and sshfs in OS X
wr11 Apr 19, 2007 07:32 PM
Yeah the macfuse project is really very cool - and works well.

I do, however, prefer the Transmit / text editor method.
kamina Apr 20, 2007 03:24 PM
I prefer just using vi.
olePigeon Apr 20, 2007 03:56 PM
Quote, Originally Posted by kamina (Post 3360932)
I prefer just using vi.
I prefer just using emacs. *ducks*
Geobunny Apr 20, 2007 04:41 PM
Quote, Originally Posted by kamina (Post 3360932)
I prefer just using vi.
Oh dear, there's always one, isn't there! :lol:

Can I be bothered having the vi vs. emacs vs. nano debate? Actually, no I can't, so here's a wee song instead (and here's the tune if you can't remember how the verses go)

Apologies to everyone who heard it first time around....18 years ago!
All times are GMT -4. The time now is 12:32 PM.

Copyright © 2005-2007 MacNN. All rights reserved.
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2016, vBulletin Solutions, Inc.

Content Relevant URLs by vBSEO 3.3.2