Remote edit is important, the ways I frequently use are
use nvim inside ssh, requires the remote machine to have nvim installed, and you will have to deal with latency.
use sshfs to mount remote directory to local. You can use your local editor which is great, but you still have to deal with latency.
use scp or rsync to copy the files back and forth, giving you the lowest latency. But it’s not very convenient.
Below I will describe the new convenient and low latency magic I have found! owo
In short it works as follows:
Mount the remote directory to local using rclone
rclone mount remote:remote_path local_path --vfs-cache-mode writes
mkdir local_path
to create the local path for mounting.--daemon
flag can be added to run it in the background. According to their manual, this deamon flag is not effective in Windows.--vfs-cache-mode writes
flag is optional but recommendable, it will cache the files that you open to write locally, making the editing experience smoother.Edit the files!
nvim local_path/file
Unmount the remote directory
If it becomes unresponsive, or you need to stop it, you can Ctrl+C to stop it or kill it, and unmount it by running
killall rclone # kills all rclone processes
fusermount -u local_path # unmounts the local path
# or
umount local_path # unmounts the local path, alternative way
That’s it! very simple and you can enjoy the low latency editing experience just like it is local! The only latency happens when you try to save your file.
It should be easy to install rclone as most distros already package it. Their downloading website is Download Rclone.
sudo apt install rclone # for debian based distros
sudo pacman -S rclone # for arch based distros
And it is even available on Windows OwO! (Head to the official link, I haven’t tested it on Windows since I don’t use Windows)
One of the distinct feature of rclone is, it must be configured before you can use it. You cannot run it like ssh user@host
or rsync -avz user@host:/path/to/file /local/path
, these will not work. You must configure each remote you will use (and have rclone installed on the remote as well), the configuration are as follows, choose the way that suits you the best.
Simply run the command, and you will answer like 20 questions
rclone config
This is the approach I prefered. Head to the path ~/.config/rclone/rclone.conf
(create the path and file if it does not exist) and add the following (which is the configuration I use)
[YourRemoteName]
type = sftp
key_file = /home/eiko/.ssh/YourKeyFile
shell_type = unix
md5sum_command = md5sum
sha1sum_command = sha1sum
host = YourRemoteAddress
user = YourRemoteUsername
Replace the YourRemoteName
, YourKeyFile
, YourRemoteAddress
, and YourRemoteUsername
with your own values owo! The type
can be sftp
, ftp
, webdav
, etc. Sftp transmits data in an encrypted way so I usually use it. You can find the full list of supported remotes in their manual owo, or during the interactive configuration.
Rclone is a very powerful and versatile tool, I use it to backup and sync my files and cellphone through all my devices. It is real magic and you will definitely want to learn more about it! owo