This tutorial will show you how to use SSHFS to mount a remote VPS as storage for your HostDoc KVM.
Imagine that you have an OpenVZ or KVM VPS somewhere that has plenty of storage, lets say a 100GB OpenVZ, and you have a KVM that you’d like to run Plex on, you can use SSHFS to mount your VZ storage VPS as a directory (for example /mnt/100gbVZ/) and it will appear like a normal directory.
The first thing we need to do is install sshfs:
apt install -y sshfs
We need to make a directory that will be our local mount point for the remote file system, I will stick with the example, but you can change this to whatever you like:
Now, the next thing we need to do is actually connect to the remote server, and mount it as a local directory:
sshfs -o allow_other email@example.com:/ /mnt/100gbVZ/
The above will mount the root directory of the remote VPS to /mnt/100gbVZ on our HostDoc KVM.
If you want to mount a different directory on the remote VPS, for example /var/plexmedia/ then we could do this:
sshfs -o allow_other firstname.lastname@example.org:/var/plexmedia/ /mnt/100gbVZ/
To unmount that, just use the umount command:
If you don’t want to type the password each time, you can specifiy a password in the command - it’s not the best idea from a security point of view, but if you aren’t worried you can proceed:
sshfs -o allow_other,password_stdin user@remotevps:/ /var/100gbVZ/ <<< "p4ssw0rd"
Connecting to SSH on a different port
If your SSH server is running on a port other than 22, you can use the -p flag. For example, if SSH is running on port 12345:
sshfs -o allow_other email@example.com:/var/plexmedia/ /mnt/100gbVZ/ -p 12345
Or you can combine automation with a different port:
sshfs -o allow_other,password_stdin user@remotevps:/ /var/100gbVZ/ -p 12345 <<< "p4ssw0rd"
This won’t be the fastest way to access files on a remote file system, network latency can really affect the performance.
This will only work on a KVM, or OpenVZ/LXC with FUSE enabled.