• Steel Thunder

Creating a SSH Filesystem Mount

Updated: Jun 16, 2020

I was looking to create a secure mount on boot solution and found that SSHFS was perfect. You can create one easily by doing the following:

Install fuse-sshfs:

yum install fuse-sshfs

Create an ssh key if you don't already have one and then simplify it by creating a ssh config file. Since you will be utilizing /etc/fstab to auto mount SSHFS on boot, you'll need to make sure the config file is created under /root/.ssh/config

If you are utilizing another user for security reasons, you can still do so while having root create the initial mount. The following is a config file template for doing so:

Host <host nickname>

HostName <name or ip address>

Port <portnumber>

User <usernameofsshkeyowner>

ServerAliveInterval 120

IdentitiesOnly yes

IdentityFile /home/<usernameofsshkeyowner>/.ssh/id_rsa

You will need to manually create the sshfs mount at least once so that the host's signature is added to the /root/.ssh/known_hosts file. You can do so with the following:

fuse-sshfs <host nickname>:<hostdirectoryofinterest> <mount directory>

The /etc/fstab file should include the following as the last line:

<host nickname>:<hostdirectoryofinterest> <mount directory> fuse.sshfs defaults,allow_other,_netdev,reconnect 0 0

You should then be able to reboot the machine and find that the mount has been mounted after a reboot. (mount -a should also work without rebooting)

14 views0 comments

Recent Posts

See All

I'm migrating site content from my Azure MCV site to a new hosting platform. This is being performed so I can shift to a lower cost platform for basic web hosting while freeing up Azure resources for