Sunday, December 13, 2009

Mounting Remote Directories with SSHFS

Recently, I was demonstrating ssh tunneling to some of my students. One of them asked me how they access remote directories in GUI. This can be achieved in several ways. Let us try mounting via ssh.

Install the sshfs package on the machine you want to mount the remote directory.

$ sudo apt-get instlall sshfs

You need ssh server running on the remote machine and you must have a valid username and password on that machine.
In the example below, I am assuming that you have an account named ubg on a remote_server . Replace remote_server with its IP address. /home/ubg/remote is the local folder into which the remote folder will be mapped. Now let us mount the remote directory.

$ sudo sshfs ubg@remote_server: /hume/ubg/remote

This will mount the home folder of the user ubg on remote_server to the folder /home/ubg/remote on the local machine. You can mount any folder on which you have read permission to the local machine. See this example.

$ sudo sshfs ubg@remote_server:/usr/share/doc /hume/ubg/remote

Now, you can access the remote folder via nautilus like a local folder.

You can unmount the remote folder with

$ sudo fusermount -u /hume/ubg/remote


Anonymous said...

How can i find the ip address of the remote system from my system?

Can i use who command in bash to find it?

spec2 said...

ubuntu provides a gui utility for accessing folders on remote mechine.
go to
places->connect to server
select ssh protocol and enter the details such as port no, username ,password etc.its loads users folder our mechine.
i also tried the command
ssh -X ec08xx@192.168.0.x [command]
also i want to know more about -f and -n options.
also my congrats for becoming the principle of ceal.
wish you merry xmas

Anonymous said...

how can I specify a port for the remote machine in that line of code?

$ sudo sshfs ubg@remote_server:/usr/share/doc /home/ubg/remote

i mean, where do i put the flag -p 80 for instance

Anonymous said...

$ sudo sshfs -p 80 ubg@remote_server:/usr/share/doc /home/ubg/remote