chmod +x /usr/bin/fusermount
Today I was wanting to edit a few image files on a remote machine. Now, when I typically need to transfer files across the internet, I will transfer them through sftp. I prefer this method simply because I already have an ssh server running on my target machine, so I don’t need to install anything extra (such as ftp or samba).
In light of this, I figured that since you can transfer files through an ssh tunnel, you must be able to remotely mount a file system through ssh.
Enter sshfs
I searched around a bit and the first thing I found was sshfs (ssh file system). It allows you to remotely mount files systems through ssh/fuse (yay). <pre> apt-get install sshfs </pre> Before we get around to actually mounting the remote filesystem, we need to change permissions on one thing so we can use this as a non-root user since we don’t run GUIs as root (at least I hope you all don’t). Let’s add execute permissions for all to the fusermount command.
chmod +x /usr/bin/fusermount
Now that we have done that, we can proceed with mounting. I create a mount location in my home directory for ease of access.
mkdir ~/mount
Now that we have a place to mount our remote location, let’s actually perform the dastardly deed.
sshfs <username>@<RemoteServer>:<RemotePath> <LocalMountPoint>
A good example of this is
sshfs jimneycricket@nowhereissomewhere:/home/jimneycricket ~/mount
It will ask you for a password. Supply the password and all should be well. Open up your file manager and navigate to \~/mount and you should see the files on your remote server (in this case, the home directory for jimneycricket).
To unmount, you need to log in as root/sudo and run umount \~/mount.
Finally, if you change the ports that ssh listens to on all of your ssh servers, you need to add one extra bit to the sshfs string. To connect to a port other than the default 22, put
-p <port>
just after sshfs and you’ll be set.
Yay for seamless mounting!
Category:Linux