22 C
Texas

Mount remote directory using sshfs

Though, multiple tools are present for remote drive mount in Linux. SSHFS is one of the popular tools for the same. Essentially, FTP works at the backend to mount the remote file system in the scenario. So, it is really essential to have ssh service installed on both sides.

Prerequisites to install sshfs

Here, for the demonstration I will be using Mint OS for Server and a client Mint machine.

My Server IP – 192.168.135.128/24

Client IP – 192.168.135.129/24

- Advertisement -

User with similar name should similar with both of the parties (server and client).

Install sshfs Services

Install services

$ sudo apt-get update 
$ sudo apt-get install sshfs

Mount File System over remote

Here, we require to create a demonstration directory, required to get share over sshfs remotely. First, confirm that you are able to connect to remote sessions. Make sure ssh ports are allowed over the firewall. You can refer to this article to see how to allow or block ports on a Linux system.

Start firewall service, first.

$ sudo ufw enable

Enable ssh on the firewall.

$ sudo ufw allow ssh

Have a look, whether service is up or not ? Repeat same for both server and client.

$ ufw status numbered

Output

Status: active
To Action From
-- ------ ----
[ 1] 22/tcp ALLOW IN Anywhere
[ 2] 22/tcp (v6) ALLOW IN Anywhere (v6)

Create a directoy on 192.168.135.129, this directory will be used as mount.

$ mkdir sshmount

Now mount that directory to remote i.e. 192.168.135.128. Let’s mount drive.

$ sshfs [email protected]:/home/mint/sshmount /tmp/

But, I got following error.

fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the 'nonempty' mount option

Now you

To avoid this error, we will use -o option with ‘nonempty’ argument.

$ sshfs -o nonempty [email protected]:/home/mint/sshmount /tmp/

It will be mounted successfully now.

Now, cd to /tmp directory and try to create text file, we will see whether text is visible in original directory as well or not.

Create text file in mounted /tmp directory.

$ cd /tmp && touch example.txt 

Lets switch to other machine and see, if that created file is visible here or not.

Login to 192.168.135.129

$ cd /home/mint/sshmount 
$ ls 

Conclusion

To mount file system securely on a remote desktop, sshfs can be a quick method. Some time it might show some errors while mounting, use -o option with required argument.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article