Linux via SSH mount remote file system details
- 2021-01-18 06:47:18
- OfStack
Features of SSHFS:
FUSE (Best User Space File System Framework for Linux)
Multithreading: There can be multiple requests on the server
Allows large reads (Max. 64k)
Cache directory contents
Step 1: Install fuse-sshfs
For centos/rhel users, fuse sshfs is available under epel repository, so make sure you have epel repository installed on your system. Now run the following command to install it
On CENTOS/RHELL:
#yum install fuse-sshfs
On Ubuntu and Dabian:
$ sudo apt-get update
$ sudo apt-get install sshfs
Step 2: Load the remote directory
Let's use sshfs to mount the remote server directory to ensure that the ssh server running on the remote system is properly connected to the ssh of the system.
First create the mount point
# mkdir /mntssh
Let's mount the remote directory. For this example, we will install the /home/remoteuser directory from the 192.168.1.12 (remote.example.com) system to the local system.
# sshfs laitkor@remote.example.com:/home/remoteuser /opt/mntssh
The 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
remoteuser@remote.example.com's password:
Step 3: Verify the installation
After mounting the remote file system on the local mount point, verify 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)remoteuser@remote.example.com:/home/remoteuser on /mntssh type fuse.sshfs (rw,nosuid,nodev)
Navigate to your mount point as well and you will see the files from the remote system
# cd /mntssh
# ls
Step 4: Mount the directory at system boot time
If you want to mount the remote file system automatically every time the system is rebooted, add the following entry to the file/etc/fstab. Ensure that the key-based ES73en is installed between the remote and local systems.
remoteuser@remote.example.com:/home/remoteuser /mntssh fuse.sshfs defaults 0 0
Step 5: Unmount the directory
If your work is finished and you no longer need the installed directory, simply uninstall it using the following command.
#umount / mntssh