For many reasons, you can find yourself working with a server where many and constant changes need to be done. This usually implies doing a modification to a file, uploading it, testing it, modifying something again, uploading, and repeating.
There’s many different approaches to manage this routine.
The 1st option is editing from the terminal. This is not bad, as Vim, Nano (I previously wrote how to activate markdown in Nano), and other command line editors are powerful options and allow us to fulfill most of the tasks. However, it can be a headache editing several files, not being able to use the mouse’s scroll wheel (that is there to be used!), or the beautify plugin.
Another option that works perfectly fine requires the creation of Grunt tasks. However, we could lack a little bit of flexibility if we do many different tasks. Also, we still need to spend some extra time creating connections and uploading the files.
We could also install a X server and access through remote desktop to our server, but that will imply an use of extra resources (memory, space, and bandwidth… And therefore, money) that could be used for more interesting things.
At the moment, the way I’m using to bypass all this trouble and make my life easier, consists in using SSHFS and Fuse. Basically, I will have my remote drive mounted like a local drive, and I can use all the editors I want, and I can use drag’n’drop to easily play with my files. Something similar can be done using the FTP protocol, but this is inherently insecure. That’s why I decided to use SFTP in this case, which is FTP implemented under SSH.
So… How I do it? Easy. First, SSH access is needed. If you can connect to the server through SSH to your server, you can use sftp to transfer files from/to your server, as they explain in DigitalOcean.
SFTP is pretty cool by itself, but we can make it awesome. Oh, laziness, the mother of the best inventions… SSHFS will be the responsible to mount the remote folder in our system. The installation is a piece of cake in Ubuntu and derivatives:
sudo aptitude update sudo aptitude install sshfs sudo adduser $USERNAME fuse mkdir ~/Desktop/sftp
A reboot is required to complete the process.
Then, for mounting the remote folder a simple command line is required:
sshfs HOSTuser@remote.host.or.ip:/host/dir/to/mount ~/Desktop/sftp
And for unmounting:
fusermount -u ~/Desktop/sftp
My suggestion is to mount the folder the first time as
sshfs HOSTuser@remote.host.or.ip:/ ~/Desktop/sftp
in order to find out which folder is mounted as default, as it depends on the server and user configuration.
If you have some error like
fusermount: failed to open /dev/fuse: No such file or directory
there’s a easy workaround:
sudo mknod -m 666 /dev/fuse c 10 229
You can create an alias, or a .bashrc entry to automatise this task every time you boot your computer, but I rather prefer to do it manually when I consider is the moment. That’s why I created 2 easy scripts:
#!/bin/bash # Mount sftp folder sshfs TheUser@YourIP:/home/TheUser ~/Desktop/sftp echo "Done"
#!/bin/bash # Unmount sftp folder fusermount -u ~/Desktop/sftp echo "Done"
Cool, isn’t it? Just remember to be careful, I’m not responsible if something goes wrong. If you want to know a little bit more, you can visit damontimm‘s website, where I took much of the information from.