Sodface | Tech

Install SSHFS

SSHFS is a userland package for mounting directories on remote servers over SSH.

[[email protected] ~]$ sudo dnf install sshfs
[sudo] password for sodface: 
Last metadata expiration check: 0:16:38 ago on Sun 03 Feb 2019 01:20:24 PM EST.
Dependencies resolved.
 Package                       Arch                      Version                            Repository                 Size
 fuse-sshfs                    x86_64                    3.4.0-1.fc29                       fedora                     55 k
Installing dependencies:
 fuse3                         x86_64                    3.2.3-14.fc29                      fedora                     43 k

Transaction Summary
Install  2 Packages

Total download size: 98 k
Installed size: 219 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): fuse3-3.2.3-14.fc29.x86_64.rpm                                                        31 kB/s |  43 kB     00:01    
(2/2): fuse-sshfs-3.4.0-1.fc29.x86_64.rpm                                                    40 kB/s |  55 kB     00:01    
Total                                                                                        33 kB/s |  98 kB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                    1/1 
  Installing       : fuse3-3.2.3-14.fc29.x86_64                                                                         1/2 
  Installing       : fuse-sshfs-3.4.0-1.fc29.x86_64                                                                     2/2 
  Running scriptlet: fuse-sshfs-3.4.0-1.fc29.x86_64                                                                     2/2 
  Verifying        : fuse-sshfs-3.4.0-1.fc29.x86_64                                                                     1/2 
  Verifying        : fuse3-3.2.3-14.fc29.x86_64                                                                         2/2 

  fuse-sshfs-3.4.0-1.fc29.x86_64                                 fuse3-3.2.3-14.fc29.x86_64                                

[[email protected] ~]$ 

Manual Mount First

- Create the mountpoint - Add the server to /etc/hosts - Manually mount the sshfs share first so you can accept the key - Note- do this both as root and as the normal user, the server key needs to be in the root user's known hosts file also since it is root that mounts it at boot - Unmount and remount to make sure you it will work without any user prompting

[[email protected] ~]$ mkdir -p /home/sodface/sodserve/calibre
[[email protected] ~]$ su
[[email protected] sodface]# echo " sodserve" >> /etc/hosts
[[email protected] sodface]# exit
[[email protected] ~]$ rm .ssh/known_hosts 
[[email protected] ~]$ sshfs [email protected]:/home/data/calibre /home/sodface/sodserve/calibre/
The authenticity of host 'sodserve (' can't be established.
ECDSA key fingerprint is SHA256:PEzqv13jFWs7yCRIamNECvVyjm/eMijv6VXlwUoelY4.
Are you sure you want to continue connecting (yes/no)? yes
[[email protected] ~]$ ls sodserve/calibre/

Output Snipped

[[email protected] ~]$ fusermount3 -u sodserve/calibre/
[[email protected] ~]$ ls sodserve/calibre/
[[email protected] ~]$ sshfs [email protected]:/home/data/calibre /home/sodface/sodserve/calibre/
[[email protected] ~]$ ls sodserve/calibre/

Output Snipped

[[email protected] ~]$ fusermount3 -u sodserve/calibre/

Setup the systemd Mount

- Create the systemd unit file (filename matches the mount point) - reload and start the daemon - check the mount and reboot and check the mount

[[email protected] system]# cat /lib/systemd/system/home-sodface-sodserve-calibre.mount 
Description=Mount remote fs with sshfs


[email protected]:/home/data/calibre

[[email protected] system]# systemctl daemon-reload 
[[email protected] system]# systemctl enable home-sodface-sodserve-calibre.mount 
Created symlink /etc/systemd/system/ → /usr/lib/systemd/system/home-sodface-sodserve-calibre.mount.
[[email protected] system]# systemctl start home-sodface-sodserve-calibre.mount
[[email protected] system]# ls /home/sodface/sodserve/calibre/

Output Snipped