You are here
Home > Ubuntu > Sharing folder using ssh

Sharing folder using ssh

FUSE – Filesystem in Userspace

FUSE is a Linux kernel module also available for FreeBSD, OpenSolaris and Mac OS X that allows non-privileged users to create their own file systems without the need to write any kernel code. This is achieved by running the file system code in user space, while the FUSE module only provides a "bridge" to the actual kernel interfaces. FUSE was officially merged into the mainstream Linux kernel tree in kernel version 2.6.14.

You need to use SSHFS to access to a remote filesystem through SSH

Step # 1: Download and Install FUSE

Browse fuse home page and download latest source code tar ball.

Untar source code:

# tar -zxvf fuse-2.6.5.tar.gz

Compile and Install fuse:

# cd fuse-2.6.5

# ./configure

# make

# make install

Step # 2: Configure Fuse shared libraries loading (optional)

You need to configure dynamic linker run time bindings using ldconfig command so that sshfs command can load shared libraries such as libfuse.so.2 if shared libraies not loaded automatically.

# vi /etc/ld.so.conf.d/fuse.conf

Append following path:

/usr/local/lib

Run ldconfig:

# ldconfig

Step # 3: Install sshfs

http://fossies.org/linux/misc/sshfs-fuse-2.3.tar.gz/

Now fuse is loaded and ready to use. Now you need sshfs to access and mount file system using ssh. Browse sshfs home page and download latest source code tar ball or using wget download the file from following url.

# wget http://fossies.org/linux/misc/sshfs-fuse-2.3.tar.gz

Untar source code:

# tar -zxvf sshfs-fuse-2.3.tar.gz

Compile and Install fuse:

# cd sshfs-fuse-2.3

# ./configure

# make

# make install

Mounting your remote filesystem

Now you have working setup, all you need to do is mount a filesystem under Linux. First create a mount point:

# mkdir /mnt/admin

Now mount a remote server filesystem using sshfs command:

# sshfs smartstudents@systemadministrator.in:/home/smartstudents/ /mnt/admin
Where,

sshfs : SSHFS is a command name

smartstudents@systemadministrator.in: – smartstudents is ssh username and ststemadministrator .in is my remote ssh server.

/mnt/admin : a local mount point

When promoted supply smartstudents (ssh user) password. Make sure you replace username and hostname as per your requirements.

Now you can access your filesystem securely using Internet or your LAN/WAN:

# cd /mnt/admin

# ls

# cp -a /ftpdata .

Lets have a look what is now mounted by using mount command

#mount

The highligted portion shows the sshfs mount worked.

/dev/sda3 on / type ext4 (rw,acl,user_xattr)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

debugfs on /sys/kernel/debug type debugfs (rw)

devtmpfs on /dev type devtmpfs (rw,mode=0755)

tmpfs on /dev/shm type tmpfs (rw,mode=1777)

devpts on /dev/pts type devpts (rw,mode=0620,gid=5)

/dev/sda1 on /boot type ext4 (rw,acl,user_xattr)

securityfs on /sys/kernel/security type securityfs (rw)

smartstudents@123.235.105.108:/home/smartstudnts/ on /mnt/rec type fuse.sshfs (rw,nosuid,nodev,max_read=65536)

To unmount file system just type:

# fusermount -u /mnt/admin

(or)

# umount /mnt/admin

Leave a Reply

Top