SSH is a secure remote connection protocol used to manage and get a shell from remote systems. SSH is mainly used by Linux distributions. SSH also provides a secure file share over the network which is names as SSHFS.
Install SSHFS Client For Linux
SSHFS is named as file system. We need to install SSHFS file system package for Linux systems.
Ubuntu, Debian, Mint, Kali
$ sudo apt install sshfs
CentOS, Fedora, RedHat
$ sudo yum install sshfs
Install SSHFS Client For Windows
Windows provides different 3rd party applications those supports SSH and SSHFS. Here a list of them.
In this tutorial, we will use the most popular one
WinSCP. WinSCP can be downloaded from the following link and installed by
Mount For Linux
Linux can mount SSHFS file systems in different ways. In this part, we will use
sshfs command directly. We will provide the remote system IP address or hostname with the path we want to mount. We will also provide the local path we want to mount to. We can also use options about the SSHFS file system.
$ sudo sshfs email@example.com:/home/ismail /mnt
We will use
sudo in order to mount to the
/mnt. We will also provide remote user which is
ismail in this case.
List SSHFS Mounts
We can list all ready mounted SSHFS file systems with the
mount command. We will filter with the
grep file like below.
$ mount | grep sshfs
Allow Others To Read and Write For SSHFS
One of the most faced problems is writing to the SSHFS mounted directories. Because during mount we use
sudo which will mount with the
root privileges. This will cause other users cannot read or write to the mounted directories. We can use
-o option with the
allow_other to enable to read and write to the SSHFS mounted directories.
$ sudo sshfs -o allow_other firstname.lastname@example.org:/home/ismail /mnt
Provide SSH Private Key For Authentication
SSHFS service is provided over SSH port and uses SSH for authentication. SSH can authenticate users in different ways like password, private key etc. We can use a certificate in order to authenticate the user. In this example we will use
IdentityFile option with the certificate path.
$ sudo sshfs -o allow_other,IdentityFile=~/.ssh/id_rsa email@example.com:/home/ismail /mnt
Mount For Windows
We will just provide the IP address or Host name, username and password for the SSHFS mmount. We can also change the drive letter where the remote system will be mount.
UnMount For Linux
We can unmount the SSHFS file system for Linux distributions. We just need to provide the path we have already mounted. In this example, we will unmount from
/mnt with the
umount command. Keep in mind that the mounted path shouldn’t be in use.
$ sudo umount /mnt