Sodface | Tech

Install SSHFS

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

[sodface@hp-envy ~]$ 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                                

[sodface@hp-envy ~]$ 

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

[sodface@hp-envy ~]$ mkdir -p /home/sodface/sodserve/calibre
[sodface@hp-envy ~]$ su
[root@hp-envy sodface]# echo " sodserve" >> /etc/hosts
[root@hp-envy sodface]# exit
[sodface@hp-envy ~]$ rm .ssh/known_hosts 
[sodface@hp-envy ~]$ sshfs sodface@sodserve:/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
[sodface@hp-envy ~]$ ls sodserve/calibre/

Output Snipped

[sodface@hp-envy ~]$ fusermount3 -u sodserve/calibre/
[sodface@hp-envy ~]$ ls sodserve/calibre/
[sodface@hp-envy ~]$ sshfs sodface@sodserve:/home/data/calibre /home/sodface/sodserve/calibre/
[sodface@hp-envy ~]$ ls sodserve/calibre/

Output Snipped

[sodface@hp-envy ~]$ 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

[root@hp-envy system]# cat /lib/systemd/system/home-sodface-sodserve-calibre.mount 
Description=Mount remote fs with sshfs



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

Output Snipped