Wednesday, August 24, 2016

FUSE (Filesystem in Userspace)

FUSE (Filesystem in Userspace)

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

FUSE (Filesystem in Userspace):- 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.
1. Login to your linux server as root
2. Install fuse-sshfs
[root@shekhar ~]# yum install fuse-sshfs

2. Create a mount directory
[root@shekhar ~]# mkdir /mnt/shekhar

3. Mount the remote directory
[root@shekhar ~]# sshfs user@192.168.8.9:/mySharePath /mnt/shekhar/

To unmount the drive::-
[root@shekhar ~]# umount /mnt/ssh

To unmount the drive configure ssh and autofs

1. log in with user and change you directory:-
[root@shekhar ~]$
[root@shekhar ~]$cd .ssh 
[root@shekhar ~]$ ll
[root@shekhar ~]$ known_hosts (you will get this file which contain all the public key of the remote host.
2. Create the cryptographic Key on FreeBSD / Linux / UNIX workstation, enter:-
[root@shekhar ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/noc/.ssh/id_rsa):



note:- give the paraphrase you want or leave empty
[root@shekhar ~]$ ls -l (you will see the public key as well private key)
[root@shekhar ~]$ id_rsa : identification (private) key

id_rsa.pub : public key3. Use scp to copy the id_rsa.pub to the server you want password less and secure communication:- 
[noc@noc .ssh]$scp id_rsa.pub root@192.168.122.90:.ssh/authorized_keys
4. Now ssh from your server:- 
[root@shekhar ~]$ssh root@192.168.122.90

this will logged in whitout prompting for password.
5.Changing the pass-phrase on workstation:-
[root@shekhar ~]$ ssh-keygen -p 
Installing Install autofs:-
[root@shekhar ~]$ yum install autofs
Get the user and group id of the user you wish to control the share:-In this example I’m going to use the root account
[root@shekhar ~]$cat /etc/passwd | grep root
root:x:0:0:root:/root:/bin/bash

Edit the /etc/auto.master file and add the following line under the line for /misc, substituting your chosen user and group id’s:-
[root@shekhar ~]$ vim /etc/auto.master
/mnt/ssh /etc/auto.sshfs uid=0,gid=0,--timeout=30,--ghost 
Now create the file /etc/auto.sshfs and add the following line to it
[root@shekhar ~]$ vim /etc/auto.sshfs
bar fstype=fuse,rw,nodev,nonempty,noatime,allow_other,max_read=65536 :sshfs\#root@192.168.122.90\:/mnt/popo 
this will mount the directory in /mnt/bar

No comments:

Post a Comment