Skip to end of metadata
Go to start of metadata

SSHFS is a filesystem client to mount and interact with directories and files located on a remote server or workstation over a normal ssh connection.

Install SSHFS


To mount directory in remote server, you will need to install SSHFS

sudo yum -y install sshfs


Once installed, you can simply try to mount your remote server. Note that the remote server must support SSH.

sshfs ck@192.168.10.7:/data/disk1 /mnt/disk1


Auto-mount remote directory while server boot

If you want to setup auto-mounting remote directory, you need to create your own signature like below

ssh-keygen -t rsa -b 4096 -C "ck@ckii.com"

While you create your own key, you will need to put your location where to save your key. By default, it will be saved to /YOUR_HOME_DIR/.ssh/id_rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/home/ck/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ck/.ssh/id_rsa.
Your public key has been saved in /home/ck/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:EociK2DFhCX85+RuLAoj2pGdr/QXqbNzSiAzUwxOdV4 ck@ckii.com
The key's randomart image is:
+---[RSA 4096]----+
| .+*= o E        |
| oo=.o + .       |
|  +.o + . .      |
| . o. o+ .       |
|  = o=. S.       |
|   B +o o        |
|  o +..o .       |
|...o +B +        |
|o.ooo+=O         |
+----[SHA256]-----+

Follow-up action you need to do is copying ID by ssh-copy-id <id@remote_server>

ssh-copy-id ck@192.168.10.7

If everything went well, you will be able to connect to your server without typing pass-phrase like before.


In order to auto-mount remote directory, you will need to add following lines at /etc/fstab

user_id@server_address:<where_to_mount> <target_directory> fuse.sshfs defaults,idmap=user,allow_other,delay_connect,reconnect,_netdev,users,IdentityFile=<your_key_location> 0 0

Below is an working example

kurapa@192.168.10.7:/data/disk1 /mnt/disk1 fuse.sshfs defaults,idmap=user,allow_other,delay_connect,reconnect,_netdev,users,IdentityFile=/home/ck/.ssh/id_rsa 0 0

Note that I had a problem that the CentOS server can't auto-mount by sshfs in some cases, delay_connect solved my paint points, and it doesn't make any performance issues but stable auto-mounting in the latest multi-core servers.