SSHFS mount remote file system locally over SSH

Apr 21, 2012 | Linux, shell

SSHFS is a filesystem client based on the SSH File Transfer Protocol. Since most SSH servers already support this protocol it is very easy to set up: i.e. on the server side there’s nothing to do. On the client side mounting the filesystem is as easy as logging into the server with ssh.

So we have two systems remote.kpsn.pie and local.kpsn.pie. we want to mount directory /home/homer/supercooldir from remote.kpsn.pie as /home/user/remote in local.kpsn.pie and for this discussion on remote system your user is called homer. we will be doing all these commands as user on local system and not root.

This requires SSH key based authentication to be working between the machines prior to this being setup. check out other tutorial on this setup.

so first off you install sshfs on local.kpsn.pie

Now you need to make the folder in local.kpsn.org.pie where you will be mounting the remote folder so:

now we go about actually mounting the remote directory to the local one we made so:

What if you have a different port for ssh on remote? well simply use the -p flag, say the port is 12345:

to unmount you type:

to automagically mount this at startup edit /etc/rc.local

and insert this line ABOVE the line saying exit 0

that last “user” is the local machine user. this allows the command to be run as the local machine user so the drive gets mounted properly.

this all is written for ubuntu but should work elsewhere. lemme know of any questions or concerns.

Pin It on Pinterest

Share This

Share this post with your friends!