Remote Access With Sublime Text 3

I want to use Sublime Text 3 directly with my external servers so that I can avoid needing to upload changed files from my desktop using another FTP program. I also want to be able to launch it from the command line.

My first approach was to install ST3 directly on one my servers (T60). While this made it available on the server, it also meant that I needed to be on the server in order to access the app.

I started out at https://opensourceinside.blogspot.ca/2016/02/how-to-install-sublime-text-3-build.html . First, I made sure I was logged in to the server as myself (not as root) and then made sure I was in my home directory. Then I ran the following command to complete the install:

cd && wget https://download.sublimetext.com/sublime-text_build-3103_i386.deb && sudo dpkg -i sublime-text_build-3103_i386.deb

Next, I needed to make it possible to launch the app from the command line. I went here http://askubuntu.com/questions/273034/lauching-sublime-text-from-command-line to find more. I ran this command to to enable this capability:

sudo ln -s /opt/sublime_text/sublime_text /usr/local/bin/subl

Now all I need to do to launch ST3 from the command line is run:

subl

This works beautifully, so long as I’m working directly on the server.

I needed another approach for tunneling in remotely from my desktop machine. The simplest solution was to add the Sublime SFTP package (https://wbond.net/sublime_packages/sftp) to my desktop install.

Once added, I followed the instructions in the package description file to set up the config files. There’s a bit more on using public/private key authorization here at https://wbond.net/sublime_packages/sftp/faq#SSHKeys and at https://wbond.net/sublime_packages/sftp/settings .

Works like a charm now!

Well, almost… When I tried to upload changes to the Cake project via Sublime SFTP, I ran into a permissions error since I was not logged in as root. When installed, Cake sets the default owner & group to root:root.

When I did a chown on the app to set a new owner and group, I caused a bit of havoc. It turns out, after doing the chown, I then needed to run the following commands to update permissions on the tmp and log folders and files:

HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`
setfacl -R -m u:${HTTPDUSER}:rwx tmp
setfacl -R -d -m u:${HTTPDUSER}:rwx tmp
setfacl -R -m u:${HTTPDUSER}:rwx logs
setfacl -R -d -m u:${HTTPDUSER}:rwx logs

All good again:-)