Remotely edit files over SSH using BBEdit or TextWrangler
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

(r)emote (ed)itor (sh)ell script

We've all been there. You SSH'd into a remote machine from your Mac and need to edit a file.

Sure you could fire up pico or dust off your vi foo, but wouldn't it be nice to run a command that opened the file in a friendly, modern GUI on the Mac in front of you? Are BBEdit and TextWrangler friendly enough for you?

If so you're in luck because you've stumbled upon, a shell script that uses the finest SSH gymnastics to accomplish exactly that.


Run the following on the remote machine to install (you don't need to install anything specific to on the Mac):

curl -L > /usr/local/bin/
chmod +x /usr/local/bin/


  1. BBEdit, TextWrangler or some other App that can open sftp:// URLs installed on your Mac

  2. SSH server must be enabled on both the Mac and the remote machine. To enable the SSH server that came with your Mac, check Remote Login on the Sharing section of System Preferences.

  3. If you're connecting to a machine outside your firewall, you'll need to set up appropriate port forwarding on your router to forward SSH traffic trafic to your Mac's local IP (it's a shell script, not magic).


When run over SSH, will attempt to detect the correct IP addresses for both the Mac and the remote machine if none are specified, so in many cases most of the arguments can be omitted. Run the following on the remote machine to edit sftp://RemoteUser@RemoteHost:22//etc/hosts in BBEdit on your Mac as User: -u User /etc/hosts

Enter the password you use to log into your Mac as User when prompted.

Specify a different editor with the -a parameter (any App that can open sftp:// URLs should just work): -u User -a /etc/hosts

You can use relative paths, open multiple files at once and even use wildcard patterns: -u User /etc/hosts /etc/php/php.ini conf.d/*.conf

Run with no arguments to see all options/parameters.


  • Use bash aliases to make convenient shortcuts. Por ejemplo, if you always log in to your Mac as User, maybe you'd add the following to your ~/.bash_profile on the remote machine:

    alias red=' -u User'
    alias tw=' -u User -a'
  • I recommend adding the public SSH key for your Mac user account to the remote user's ~/.ssh/authorized_keys file to prevent BBEdit/TextWrangler from prompting for the remote user's password. This gives the Mac user account the power to access the remote machine as the remote user without being prompted for a password. You have been warned.

  • In situations where it is safe to do so (local VMs and such), you can also prevent being prompted for your Mac password by adding the public SSH key of the user account on the remote machine to the ~/.ssh/authorized_keys file on your Mac. This gives the remote user the power to access your Mac as you without being prompted for a password. You have been warned.