During those last two weeks I had to do a lot of developing for some projects that I take part in, mainly in CUDA C and matlab. Through this whole experience, I had to solve various problems as to enhance my productivity. One of them was keeping track of the different branches and versions of my code, a problem solved by Git, on which I have already commented on.
Another one was in developing CUDA code on my laptop, which has a cheap and relatively slow (with today’s standards) Nvidia graphics processing unit. Although that was a good opportunity for me to debug my code on my own machine, I could never run big simulations due to the limitations of the card. So, I had to use one of the other machines on which I have access. How could I develop and run code on other machines?
Geek mode : ON
First idea : develop & debug code through ssh.
Of course this means that I had to use a terminal-based editor such as vim. Now vim is great for writing code but I could never really get accustomed to not being able to use my mouse/touchpad to move through the code. I get that for some people this is part of the game but I find it tiring. In short, I can use it just fine while editing small parts but not for actually writing more than a few lines of code each time.
Then comes the X.
Next idea is to use forwarding, thus being able to run on my computer the graphical front-ends of applications of the far-away computer. You just login to your computer via ssh -X and then can start the gui of whatever application resides on that computer. Although handy, the gui that opens is slow and not very responsive to what you do. It actually takes time to write a line of code in gedit. Since those were partial solutions, I continued to use my own laptop and try, when I had time, to find a better way to do things.
and then I discovered sshfs.
sshfs uses sftp to mount a remote folder onto your local filesystem, thus allowing to reach the files like they were in your own pc. You can open them with your local editors, run them with local commands and generally do whatsoever you like with them. On the host side, you just need to have the sshfs program, which you can easily find online.
On the remote server side, you don’t need to do much since it most certainly will have sftp functionality.
sshfs stands for secure shell filesystem and you can find more info for that here. I was able to use it in both Mac OS (leopard) and in ubuntu 12.04.
But, be aware!
First of all, don’t try to mount files at the same time from more than one computers as whatever data you use could end up corrupted.
Also, if you plan on using it on a “not so stable” network, i.e one that stands on a wireless router at home, it may happen that the connection of sshfs with the remote server fails. In that case, as sshfs tries to reconnect, it may freeze your desktop requiring in the worst case a hard reboot. I did experience such a problem and as you can see here, other people as well.
Here’s a possible solution, which involves the ssh_config file. I will try it out and let you know!