Thursday, June 11, 2009

Mounting remote folder using SSH in Ubuntu 9.04 Jaunty

To mount a directory, for example your home directoyr, from a different linux computer is easily done using SSHFS, SSH Filesystem.

First you need to make sure you can connect to the remote computer using ssh, the remote computer needs to be running sshd. Try connecting to it using the command below, if you are able to connect, you are running sshd:
ssh <your username on the remove computer>@<remote computer name or ip>

Next we need to install sshfs, ssh file system, on the local computer:
sudo apt-get install sshfs

Note: Make sure you use sudo since this will give you root/administrator rights, if you are not allowed to do this you need to be added to the admin group. Someone already a member must then write:
sudo adduser <your username> admin
Alternatively log in with a user that is a member of this group.

Fuse, Filesystem in Userspace, makes it possible for non-root users to handle filesystems, in this case let sshfs mount a remote directory. You need to make sure the fuse is loaded:
sudo modprobe fuse

Then you need to become part of the fuse group, the group of non-root users who are allowed to handle filesystems:
sudo adduser <your username> fuse

The following commands will set up permissions to access the fuse utilities:
sudo chown root:fuse /dev/fuse
sudo chmod +x /dev/fuse


Since you added yourself to a new group, you need to log out of Ubuntu for this to take effect. Do so now.

Now you can finally mount the remote folder. You will need a folder to mount the remote folder into:
mkdir <foldername>

Then all you need to do is tell sshfs to mount the remote folder:
sshfs <remote computer username>@<remote computer name or ip>:<path to folder on the remote computer> <folder on local computer>

That's it!


Now, to unmount the folder type the follwing:
fusermount -u <path to local folder>



Below is an example of what this could look like. Here the local user is "tom", the remote user is "fred" and the remote computer is "fredsComputer":

sudo apt-get install sshfs
sudo modprobe fuse
sudo adduser tom fuse
sudo chown root:fuse /dev/fuse
sudo chmod +x /dev/fuse
logout
mkdir fredsHomeDirectory
sshfs fred@fredsComputer:/home/fred fredsHomeDirectory


To unmount:
fusermount -u fredsHomeDirectory



Solution found at: http://www.howtogeek.com/howto/ubuntu/how-to-mount-a-remote-folder-using-ssh-on-ubuntu/

No comments:

Post a Comment