Shashikant shah

Friday 10 January 2014

How to mount a remote directory in Linux using sshfs


You can easily mount remote server file system or your own home directory using special sshfs and fuse tools.

Step1: Installing Package on server1
On Ubuntu/Debain
[shashi@server1 ~]# apt-get install sshfs
On Redhat/CentOS/Fedora
rpm -ivh fuse-sshfs-1.8-1.el5.rf.i386.rpm
My local mount point: /mnt/ssh

[shashi@server1 ~]# mkdir /mnt/ssh

Step2: I will mount server2(192.168.0.102) root directory in server1. Run this command in server1.
Its a temporary mount.

[shashi@server1 ~]# sshfs root@192.168.0.102:/ /mnt/ssh/

Step3: check mount point :-
[shashi@server1 ~]# mount -a
[shashi@server1 ~]# mount & df -h

root@192.168.0.101:/ on /mnt/ssh/ type fuse.sshfs (rw,nosuid,nodev,max_read=65536)

Step4So what about mounting it permanently?. We can do it by editing fstab file

[shashi@server1 ~]# vi /etc/fstab

go to last line and type below line

sshfs#root@192.168.0.102:/ /mnt/ssh fuse defaults 0 0

[shashi@server1 ~]# mount -a

Step5: What about unmounting this drive?
[shashi@server1 ~] # umount /mnt/ssh
OR
[shashi@server1 ~]# fusermount -u /mnt/ssh

@@@@@@@@ @@ Completed @@@@@@@@@@

No comments:

Post a Comment