Home Linux & Systems Cybersecurity Cloud & DevOps Networks & Infrastructure SIEM & Monitoring DFIR & Threat Intel Development & Other All categories Projects About Tools

Share Files and Disks with SSHFS

Leer en espanol
Share Files and Disks with SSHFS

Table of contents

Secure Shell File System (SSHFS) it's a file system for Linux (and others operating systems with an implementation FUSE, just as in Mac OS X), which operates on files on a remote computer using a secure access environment. On the local computer where SSHFS is mounted, the implementation makes use of the kernel module FUSE. The practical effects of this is that the end user can interact friendly with remote files while on a server SSH,viewing them as if they were on your local computer. The subsystem is used on the remote computer SFTP of SSH.

The current implementation of SSHFS using FUSE is a rewritten version of the previous one, made by Miklos Szeredi, who also wrote FUSE.

We install sshfs

Bash
rokitoh@red-orbita~:$ apt-get install sshfs

We check that we have FUSE loaded

Bash
rokitoh@red-orbita~:$ grep  ‘fuse’  /etc/modules
text
fuse

If we don't have it we include it

Bash
rokitoh@red-orbita~:$ echo  fuse  >>  /etc/modules

and we load the module

Bash
rokitoh@red-orbita~:$ modprobe fuse

Also, to have permissions to mount it we must add the user to the fuse group.

Bash
rokitoh@red-orbita~:$ usermod -G fuse -u rokitoh

Once added we should restart the graphical environment.

Once the graphical environment has been restarted, we create the folder where we are going to mount the file.

Bash
rokitoh@red-orbita~:$ mkdir /home/rokitoh/DATOS

Now we just have to put it together.

Syntax:

Bash
rokitoh@red-orbita~:$ sshfs  <usuario>@<DIRECCION IP REMOTA>:<CARPETA REMOTA>  <CARPETA LOCAL>

In case we have changed the ssh port, we will have to indicate it with the -p parameter

Bash
rokitoh@red-orbita~:$ sshfs  -p 2222 <usuario>@<DIRECCION IP REMOTA>:<CARPETA REMOTA>  <CARPETA LOCAL>

Example:

Bash
rokitoh@red-orbita~:$ sshfs rokitoh@192.168.1.180:/media/DATOS/ /home/rokitoh/DATOS/

rokitoh@192.168.1.180′s password:

In case we want to unmount the partition it would be like this:

Bash
rokitoh@red-orbita~:$ fusermount -u /home/rokitoh/DATOS

Configure to initially mount the system.

To do this we must configure the file /etc/fstab adding the following line:

Syntax:

sshfs#<user>@<REMOTE IP ADDRESS>:<REMOTE FOLDER> <LOCAL FOLDER fuse uid=1000,gid=100,umask=0 0 0

Example

sshfs#rokitoh@192.168.1.180:/media/DATA/ /home/jositoh/DATA fuse uid=1000,gid=100,umask=0 0

So that it does not ask us for a password, we can generate the private/public keys.

In that manual I explain how to do it:

SSH connection without password

Greetings, rokitoh!!!


Comments