Last mod: 2025.01.18
Mounting remote host files via SSH to local file system
SSHFS is a powerful tool that allows you to mount remote directories over SSH and access them as if they were local directories. This is particularly useful for development on remote systems like a Raspberry Pi, as it integrates remote files into your workflow seamlessly.
Install
Install SSH Filesystem:
sudo apt-get update
sudo apt-get -y install sshfs
Mounting
Create directory under which to mount file system:
mkdir ~/remote_host
Mount remote host:
sshfs <REMOTE_USER>@<REMOTE_HOST>:<REMOTE_DIRECTORY> ~/remote_host
You need to change the parameters REMOTE_USER, REMOTE_HOST, REMOTE_DIRECTORY
For example:
sshfs tech@192.168.1.100:/opt/ ~/remote_host
Verify mounting:
cd ~/remote_host
ls
Unmount
Unmount filesystem:
fusermount -u ~/remote_host
Automount
We can also add host mounting at boot to /etc/fstab:
sshfs#<REMOTE_USER>@<REMOTE_HOST>:<REMOTE_DIRECTORY> ~/remote_host fuse defaults,allow_other 0 0
Please remember to configure your SSH keys, so that SSH login is without a password.