Linux – Open file in local text editor from within an SSH connection

linuxmacossshsublime-text-2Ubuntu

I'm not a vim guy. I'd like to be able to open log files in Sublime Text when in an SSH connection from within Terminal. Is there a way I could do this? I'm thinking there must be a command or something that could copy the file over to a temporary directory in OS X and then open it in Sublime Text, and when I save it, it'll copy back to the original location through SSH; similar to how FileZilla does it.

I'm on Mac OS X MT. The server I SSH into is running Ubuntu. I'm using Terminal.

Best Answer

You might be interested in sshfs. With that package you can mount a remote directory via SSH and use it like a local one:

sshfs user@ubuntu:/var/log /mnt/ubuntu_logs

It works completely transparent and you can use in principle every program which is installed on your local machine.

In order to use sshfs you'll need also a package that provides a Filesystem in Userspace, on OSX it's obviously called OSXFUSE (http://osxfuse.github.com).

You'll find some more information at that answer on SO and the installation procedure seems to be rather standard as two dmg packages are provided at the above linked Github site.

Related Question