So today I was working on a parallel computing project, and used some remote machines with massive CPUs, huge amount of cores and so on. We connected to these with
ssh, and ran our code there. While doing so, we needed to update our code quite often, and doing
git push &
git pull over and over again became quite tedious, as we wanted to iterate quickly on simple tasks.
Modifying files directly with
vim was our first idea, and worked quite well for small changes. But when we wanted to make bigger modifications, it was just too difficult with
vim, and we missed our good old VSCode UI.
So we looked into how we could mount the remote directory on our local computer, to be able to modify distant files outside of an
ssh session, on our laptop, and directly in VSCode. We came across this amazing article, explaining step by step how to set this up : https://susanqq.github.io/jekyll/pixyll/2017/09/05/remotefiles/.
This totally saved our lives ! 😍
Basically, it is just a matter of doing a quick
brew cask install osxfuse followed by
brew install sshfs on MacOS, or simply
apt-get install sshfs on Linux, and that's it ! You're ready to mount a remote folder using :
sshfs user@host:/remotefolder/ /localfolder
# If you have an identity file, add the following option :
# -o allow_other,defer_permissions,IdentityFile=~/.ssh/id_rsa
Beautiful, isn’t it ? Then just access the remote files at the local folder and edit them the same way you would any normal file on your laptop !
When you wish to close the connection, simply run:
That’s it, you’re ready to roll ! 👨🏼💻