Its a quick and simple way to interact with headless systems like Raspberry Pi.
What is SSHFS?
SSHFS gets its name fromSecureSHell andFileSystem.
Regular SSH lets you connect to remote computers from a terminal window.
Your commands are executed on the remote computer.
SSHFS mounts a remote file system on your local computer.
The mounted file system appears as a normal branch of your local file systems directory tree.
You pull up the remote files just like any other file on your gear.
you might browse through the directories and files using the cd command or a file web app.
Working with the files uses the applications on your local computer, not the remote computer.
For example, editing a file uses your local editor.
SSHFS isnt really suited to executing programs located on the remote computer.
Thats the sort of stuff best suited to a regular SSH connection.
But, for working with remote files, SSHFS can’t be beat.
Installing SSHFS
To use SSHFS, SSH must already be working on the remote computer.
Weve covered how to set up SSH elsewhere.
We recommendusing SSH keys instead of passwords.
If SSHFS isnt already installed on your local computer, installing it is easy.
Making a Remote Connection
We need to create a directory to act as themount point.
Its where the remote file system will be grafted onto your directory tree.
You should use your own username instead of “dave.”
On other distributions, the default location might be /run/media/ or /mnt.
Ultimately, you might create your mount point anywhere you like.
Lets take a look at our new directory.
Our directory has been created, and it is owned by root.
That wont matter though, well haveread and write permissionson the mounted file system.
The SSHFS command is long-ish, but fairly simple when you break it down.
The command consists of:
Were prompted foryourpassword because youve used the sudo command.
Were then asked for the password for the account on theremote computer.
Answer yes to this.
That doesnt happen when you mount a file system with SSHFS.
We can see the home directory of the user account on the remote computer.
Any changes you make here are made on the remote drive.
Any edits or deletions will affect the remote computer.
We ought to be able to create a new file.
Our file is created, and were the owner of it.
There was no need to use sudo.
We can navigate the mounted file system using cd, and we can copy files using the cp command.
This effectively transfers files between the remote equipment and your local computer.
The mounted file system will show up as a mounted volume.
Clicking the name of the mount point takes you straight to the remote files.
Double-clicking a file opens the app associated with that file bang out.
These actions are carried out by applications on your local computer.
If you edit a document, for example, your default local editor is launched.
Note theres no n before the m in the umount command.