Ever wanted to easily copy and paste a lot of files to a remote server, or otherwise sync automatically? What about working with the project live from your local computer and automatically sync to you test/staging server?
Well, I did want all that and recently I discovered an article by Ivan Voras on the idea of creating a distributed remote workplace. While I won't go into the article specifics, one of the technologies for creating such a remote workplace environment is the use of SSHFS.
So what is this SSHFS thingie? It allows you (local computer) to mount a remote filesystem using SFTP. Thats it. Plain and simple, using SSHFS you can have a remote folder on your computer with direct access and manipulation to the directory you choose.
Plus, since SFTP is mostly supported by default by the servers there is nothing to setup server-side for this to work.
Below, I will be describing the process for connecting using a Mac but you can refer here for the procedure for Linux and Windows.
Steps
Install FUSE and SSHFS
Simply navigate here and download and install both the FUSE for macOS and SSHFS.
Mounting a remote directory
So, after successfully installing and verifying that SSHFS is installed. Open up a terminal and write the following, replacing all content in asterisks(**), including the asterisks.
sshfs -o reconnect -o idmap=user -o follow_symlinks -C **username**@**remote host**:/ server
Note above the /
symbol. That denotes that you want to access the root directory. If you want to access the home directory replace that with .
.
The flag -o
refers to the word option
and we assign three options.
reconnect
is useful for automatically reconnecting without having to re-run the command in the event the host disconnects.
idmap=user
is useful for mapping the changes you make from your local computer seem like they were done by the remote user wand avoiding permission issues.
follow_symlinks
its pretty self examplanatory.
Note the last word where it says server
this is the path to the local directory (in this case a folder) on your local computer where the remote directory will be mounted. It is best if you create a local folder beforehand for mounting the remote directory.
Unmounting a remote directory
Use the command below to unmount the directory after you are done.
umount **name/path of local folder**
The above command is different on Windows, so please check the documentation
Conclusion
I have been using it for a while and so far this is a very handy tool to have at hand. Do you find it useful as well?