This guide will show you how to use Sublime Text editor locally to edit code files on a remote server via SSH.
This guide assumes oy already have a working SSH connection between your Mac and your remote server (with no firewall issues) and have configured SSH keys via modifying to authorized_keys file to enable SSH access.
Need a server?
UpCloud is way faster than Vulr.
Setting up slower region-specific servers can be found here. Set up a Server on Vultr here for as low as $2.5 a month or set up a Server on Digital Ocean (and get the first 2 months free ($5/m server)). I have a guide on setting up a Vultr server here or Digital Ocean server here. Don’t forget to add a free LetsEncrypt SSL Certificate and secure the server (read more here and here).
Buy a domain name from Namecheap here.
Setting up your local machine
Open Sublime Text 3 and press COMMAND+SHIFT+P to bring up the command bar and type Install and click Package Control: Install Package and click it.
Wait a few seconds for the packages list to show and type “rsub”
Ok let’s make an SSH alias to your server on your Mac by typing “sudo nano ~/.ssh/config”
Make these changes
Now we can connect to the server via SSH by typing “ssh mysrv”
After typing the server’s password you will be connected to the ssh server
Now on your local Mac load the following page in a web browser (and review the code): https://raw.github.com/aurora/rmate/master/rmate and copy the contents to the clipboard.
On the remote server (the SSH one) type:
Now paste the contents or this page into nano editor and save it and exit nano.
Now run this chmod command to make the rmate file executable.
Now on the server, we can open any text file with rmate and have it open locally in Sublime via SSH. Yes, Open a file on a server and have it automatically open in locally 🙂
If you have many files to open then create a bash file to open files with rmate
sudo nano openfilesonmac.sh
#!/bin/bash rmate index.html rmate index1.html rmate index2.html rmate index3.html rmate index4.html rmate index5.html rmate index6.html rmate index7.html rmate index8.html rmate index9.html rmate index10.html
chmod +x openfilesonmac.sh
Now we can open may remote files locally by running the bash script.
All saves in Sublime locally are sent to the server 🙂
Still here, read more articles here or use the form below to ask a question or recommend an article.
Port Forwarding with vSSH on OSX
If you use a third party ssh program like vSSH you will also need to setup port forwarding to avoid this error
Now you can open remote files locally with SSH or vSSH too.
Donate and make this blog better
Ask a question or recommend an article
[contact-form-7 id=”30″ title=”Ask a Question”]
v1.4 Added UpCloud Info.
v1.3 vSSH Port forwarding.