How I can edit files on a remote server using Textedit on my Mac through SSH

Posted on December 1 2018

Two years ago, I wrote about how I use Textedit instead of vi, vim, or nano  when editing files  in my macOS terminal. It’s still working well for me, but then I wanted it when remotely logged into other computers. Textmate can do that, but you need ruby on the remote machine and have to move over a ruby script etc. Last month I got a Ubiquity edge router x which I have no regrets with even after taking all the Cisco classes up to CCNP, configuring Cisco routers for 8 months  as an intern for the state, and running my home network off   Cisco   routers for 14 years  since 2004. I also recently  remembered a Nano Pi Neo, I’d been neglecting for 2 years, and between the 2 devices was needing to edit files on them, and the router doesn’t have ruby installed; I wanted my  Textedit. (Imagines a small child throwing a tantrum because they didn’t have their   security blanket.)
I downloaded Transmit from Panic software which is an awesome program, but its price was also a little too awesome for my wallet, so back to the drawing-board. 
I googled around looking for a way to edit files remotely through SSH connections and found out about SSHFS. FUSE is a way to create a file system in user space, or in simpler language,  to create kind of a virtual file system. SSHFS uses FUSE to create a session in-which a specific folder on a remote machine appears in a specific folder on your  machine in front of you, and then keeps them synced together. This lets me use my Textedit cheat to edit files on my mac as I have been doing for 2 years except in addition now they get synced back to the remote machine through SSH. It’s pretty cool, but if using a mac  you’ll need a few extra pieces to do it.
Hard core *nix users probably argue that a mac really doesn’t have BSD unix because it doesn’t have a package manager, but there are a few. Home brew is probably the best now though it had to compete with several others like Mac Ports and Fink for some years before emerging. You will need Home Brew to eventually get SSHFS so here’s the process for getting itFirst you’ll need Xcode command-line tools if you don’t have them already. Paste the following into the terminal:xcode-select –installand decide if you only want the CLI tools or the whole Xcode install. With only 128gb on my MacBook air, I think you can figure out which I chose. The Xcode command-line tools are very nice to have as they give you gcc clang, and other programming goodies.
Next it’s time for Home brew. Paste/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
Next we will need 2 packages before we can get sshfs working.  brew cask install osxfuse

brew install sshfs

Now we can actually make it happen. 
First on your machine make a folder where you want the files from your remote machine to momentarily exist.
Then type something like sshfs username@server-ip:/path-to-folder ~/folder-for-remote-filesObviously typing server-ip won’t work  neither will username but it should be easy to fill in your specific information there.The first time you do it, you will have to answer some questions from the security and privacy preference pane. After you say yes to them, it should work.
It seems to stay connected until the next reboot. You can do anything to those files you want and changes will sync between both devices. It’s very nice.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s