How to easily access files over SSH protocol

I am constantly using SSH to transfer files between home notebook and remote servers. Basic scp tool is great but sometimes it is more convenient to mount remote file-system to easily access files over SSH protocol.


Install sshfs utility with required dependencies:

$ sudo apt-get install sshfs

Add desired username to the fuse group:

$ sudo usermod -a -G fuse username

Basic usage

To mount remote file-system execute command:

$ sshfs user@remote_server:/remote_directory local_directory -C -o reconnect,ServerAliveInterval=30

Command above will mount remote_directory on remote_server to local local_directory and send keep alive packet every 30 seconds. It will also automatically reconnect if connection was interrupted.

To umount remote file-system execute command:

$ fusermount -u local_directory

UID/GID translation

It is not necessary for simple usage but you can translate UID on remote server.

$ sshfs remote_server:/remote_directory local_directory -C -o reconnect,ServerAliveInterval=30
$ ls -l local_directory/
total 4
drwxr-xr-x 1 1001 1001 4096 mar 27 00:24 file
$ fusermount -u local_directory
$ sshfs remote_server:/remote_directory local_directory -C -o reconnect,ServerAliveInterval=30,idmap=user
$ ls -l local_directory/
total 4
drwxr-xr-x 1 milosz 1001 4096 mar 27 00:24 file

Alternatively you can do full UID/GID translation using files.

$ cat uid_file
$ cat gid_file
$ sshfs remote_server:/remote_directory local_directory -C -o reconnect,ServerAliveInterval=30,idmap=file,uidfile=/path/to/uid_file,gidfile=/path/to/gid_file
$ ls -l local_directory/
total 4
drwxr-xr-x 1 milosz milosz 4096 mar 27 00:24 file


To not repeat yourself and use mount command add a similar entry to the fstab file:

$ grep remote_server /etc/fstab 
user@remote_server:/remote_directory /local_directory fuse.sshfs noauto,_netdev,users,reconnect,ServerAliveInterval=30 0 0


You need to retype password every time connection to the remote server is interrupted. It is normal behavior if you don't use key based authentication.

For information about using sshfs read ArchWiki - sshfs page.

Milosz Galazka's Picture

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system.

Gdansk, Poland