SSHFS is a filesystem based on the SSH File Transfer Protocol (SFTP). On remote side we just need to install SSH server, Since most of SSH servers already support this, there are nothing to do on remote server except installing SSH server. On client side we need to install fuse sshfs packages to mount remote filesystem. Newer version of SSHFS uses FUSE. The FUSE version of SSHFS is rewrite by Miklos Szeredi.
Features of SSHFS:
- Based on FUSE (Best userspace filesystem framework for linux)
- Multithreading: more than one request can be on it’s way to the server
- Allowing large reads (max 64k)
- Caching directory contents
Step 1 – Install FUSE-SSHFS
For CentOS/RHEL users, Fuse SSHFS is available under epel repository, So make sure you have install epel repository in your system. Now execute following command to install it
On CentOS/RHEL:
# yum install fuse-sshfs
On Ubuntu & Dabian:
$ sudo apt-get update $ sudo apt-get install sshfs
Step 2 – Mount Remote Directory
Let’s mount the remote server directory using sshfs. Make sure the remote system has a running ssh server with proper ssh connectivity from your system.
First, create a mount point
# mkdir /mntssh
Lets mount the remote directory. For this example we are mounting /home/remoteuser directory from 192.168.1.12 (remote.example.com) system to our local system.
# sshfs [email protected]:/home/remoteuser /opt/mntssh
[Sample output]
The authenticity of host 'remote.example.com (192.168.1.12)' can't be established. RSA key fingerprint is 77:85:9e:ff:de:2a:ef:49:68:09:9b:dc:f0:f3:09:07. Are you sure you want to continue connecting (yes/no)? yes [email protected]'s password:
Step 3 – Verify Mount
After mounting the remote filesystem on the local mount point, verify it by running the mount command.
# mount /dev/mapper/vg_svr1-lv_root on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw) /dev/sda1 on /boot type ext4 (rw)[email protected]:/home/remoteuser on /mntssh type fuse.sshfs (rw,nosuid,nodev)
Also, navigate to your mount point, you will see files therefrom remote system
# cd /mntssh # ls
Step 4 – Mount Directory on System Boot
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.
[email protected]:/home/remoteuser /mntssh fuse.sshfs defaults 0 0
Step 5 – Unmount Directory
If your work is over and you don’t need anymore the mounted directory, Simply unmount it using the following command.
# umount /mntssh
Also remove entry from /etc/fstab file
4 Comments
This did not work on RHEL 8.
sudo yum install fuse-sshfs
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Red Hat Enterprise Linux 8 for x86_64 – AppStre 41 MB/s | 26 MB 00:00
Red Hat Enterprise Linux 8 for x86_64 – BaseOS 44 MB/s | 28 MB 00:00
No match for argument: fuse-sshfs
Error: Unable to find a match: fuse-sshfs
We want to monitor SSHFS mount point with SNMP in Ubuntu but it doesn’t show any SSHFS mount point. Maybe because it is encrypted. How we can solve this?
Note: we don’t have problem with NFS.
snmpwalk -v 2c -c public localhost UCD-SNMP-MIB::dskTable
or
snmpwalk -v 2c -c public localhost HOST-RESOURCES-MIB::hrFSRemoteMountPoint
When we request with above commands there is no mountpoint in result but we have MountPoint when we do df.
df
HI i did all of the things and it has an error ” connection peer rest”
what should I do ?
Nice article… Something new for me…