Red hat linux

Mount SSHFS In Redhat / CentoS

Step 1 – Enabling the kernel module
This is a simple step – all you need to do is run the following command as the root user:

modprobe fuse

Step 2 – Installing Fuse/SSHFS

yum install fuse-sshfs sshfs

Step 3 – Using SSHFS
The commands to use SSHFS are fairly simple. To mount a remote folder, use the following commands.

# mkdir /testDirectory
# sshfs root@my.remote.server: /remotedir 
# sshfs /opt/mountdir

The directory, /remotedir , is where the remote servers’ files are visible, and can be edited if the user on the remote server has permissions to do so.

It is possible to use a private key for authentication as well. If you use a private key, make sure that you’ve set proper permissions on the identity file.

sshfs root@my.remote.server:/remotedir /mountdir -o IdentityFile=/root/the.private.key

When finished, you can unmount the remote folder with this command.

fusermount -u /mountdir

Mount Directory on System Boot

Step 4 – If you want to mount remote filesystem automatically each time when your system reboots, Add following entry to /etc/fstab file. Make sure you have have key based ssh setup between remote and local system.

root@ /opt/app_data/ebill_files fuse.sshfs IdentityFile=~/.ssh/id_rsa defaults 0 0

appadmin@ebcm_db1:/opt/ebcm_log/logs /opt/logs fuse.sshfs IdentityFile=/home/appadmin/.ssh/id_rsa,nonempty,allow_other  0    2

Leave a Reply

Your email address will not be published. Required fields are marked *