sshfs is a filesystem client based on the SSH File Transfer Protocol, and becuase it can mount remote fs on local machine, that would be great to manage remote server as a virtual disk.
So let’s try it.
1. Installation.
Fedora/RHEL all can install it via
[root@fab SPECS]# yum install fuse-sshfs -y
[root@fab SPECS]# yum install fuse-sshfs -y
REMEMBER NEVER REINVENT WHEELS LIKE COMPILING SOFTWARES ON PRODUCTION SERVER.
2. Configuration
Check if it has been installed correctly.
Fedora:
[root@fab SPECS]# modprobe fuse && systemctl list-units|grep fuse
[root@fab SPECS]# modprobe fuse && systemctl list-units|grep fuse
should turns back:
sys-module-fuse.device loaded active plugged /sys/module/fuse
sys-module-fuse.device loaded active plugged /sys/module/fuse
RHEL:
[root@fab SPECS]# modprobe fuse && lsmod|grep fuse
[root@fab SPECS]# modprobe fuse && lsmod|grep fuse
should turns back something like this:
fuse 76063 1
3. Usage.
Basic(use my example server):
sshfs root@mydomain.com:/home/mirror /mnt/mirrorfs
sshfs root@mydomain.com:/home/mirror /mnt/mirrorfs
Because I use FHS folder /mnt as mount point, so I also need root permission to mkdir mirrorfs, but this is not needed if you mount in a folder owned by yourself.
Advanced(common):
You can add -p PORT like -p 7070 to use a separate SSH port.
You can add -C to save the bandwidth.
You can add “-o reconnect” to reconnect to server when is reset by peer.
And, play with “-o sshfs_sync” will enable synchronous writes, but this will affect the speed.
You can add “-o idmap=TYPE” for user/group ID mapping, possible types are:
‘none’ no translation of the ID space (default);
‘user’ only translate UID of connecting user;
‘file’ translate UIDs/GIDs contained in uidfile/gidfile
You can also add -o password_stdin read password from stdin, such as pam_mount. But I advise you that you should use ssh certificate based authentication but not password, as this may be attacked by middle man.
You can’t input your password in stdin and let ssh receive it, so enable this option will help you doing something like:
echo xxxxxxxx | ssh root@mydomain.com
echo xxxxxxxx | ssh root@mydomain.com
In this case, you have to enable this option and edit pam_mount configuration file,
Fedora keeps it at :
/etc/security/pam_mount.conf.xml
and here is an example:
<volume fstype="fuse" path="sshfs#mirror@mydomain.com:/home/mirror/" mountpoint="~/Shared/" options="workaround=rename" />
<volume fstype="fuse" path="sshfs#mirror@mydomain.com:/home/mirror/" mountpoint="~/Shared/" options="workaround=rename" />
4. Last.
If you wnat to stop playing with this, just type:
[root@fab SPECS]# fusermount -u /mnt/mirrorfs
So let’s try it.
1. Installation.
Fedora/RHEL all can install it via
[root@fab SPECS]# yum install fuse-sshfs -y
[root@fab SPECS]# yum install fuse-sshfs -y
REMEMBER NEVER REINVENT WHEELS LIKE COMPILING SOFTWARES ON PRODUCTION SERVER.
2. Configuration
Check if it has been installed correctly.
Fedora:
[root@fab SPECS]# modprobe fuse && systemctl list-units|grep fuse
[root@fab SPECS]# modprobe fuse && systemctl list-units|grep fuse
should turns back:
sys-module-fuse.device loaded active plugged /sys/module/fuse
sys-module-fuse.device loaded active plugged /sys/module/fuse
RHEL:
[root@fab SPECS]# modprobe fuse && lsmod|grep fuse
[root@fab SPECS]# modprobe fuse && lsmod|grep fuse
should turns back something like this:
fuse 76063 1
3. Usage.
Basic(use my example server):
sshfs root@mydomain.com:/home/mirror /mnt/mirrorfs
sshfs root@mydomain.com:/home/mirror /mnt/mirrorfs
Because I use FHS folder /mnt as mount point, so I also need root permission to mkdir mirrorfs, but this is not needed if you mount in a folder owned by yourself.
Advanced(common):
You can add -p PORT like -p 7070 to use a separate SSH port.
You can add -C to save the bandwidth.
You can add “-o reconnect” to reconnect to server when is reset by peer.
And, play with “-o sshfs_sync” will enable synchronous writes, but this will affect the speed.
You can add “-o idmap=TYPE” for user/group ID mapping, possible types are:
‘none’ no translation of the ID space (default);
‘user’ only translate UID of connecting user;
‘file’ translate UIDs/GIDs contained in uidfile/gidfile
You can also add -o password_stdin read password from stdin, such as pam_mount. But I advise you that you should use ssh certificate based authentication but not password, as this may be attacked by middle man.
You can’t input your password in stdin and let ssh receive it, so enable this option will help you doing something like:
echo xxxxxxxx | ssh root@mydomain.com
echo xxxxxxxx | ssh root@mydomain.com
In this case, you have to enable this option and edit pam_mount configuration file,
Fedora keeps it at :
/etc/security/pam_mount.conf.xml
and here is an example:
<volume fstype="fuse" path="sshfs#mirror@mydomain.com:/home/mirror/" mountpoint="~/Shared/" options="workaround=rename" />
<volume fstype="fuse" path="sshfs#mirror@mydomain.com:/home/mirror/" mountpoint="~/Shared/" options="workaround=rename" />
4. Last.
If you wnat to stop playing with this, just type:
[root@fab SPECS]# fusermount -u /mnt/mirrorfs