Home

Linux: How to mount remote server files into your local machine via SSH

It is not always that we SSH into a remote server and do the heaviest of tasks. But on those longer sessions, how nice would it be if we could explore the remote files with a GUI tool (eg. Nautulius), just like if the files were local files?

The bellow tips help you do just that.

Install SSHFS

Terminal
$ sudo apt install sshfs

Using SSHFS with Basic Authentication

When your SSH requires a text password, you can use the following commands.

Terminal
$ sshfs remoteUser@remoteHost:/path/to/remote/folder /path/to/local/folder

# When done:
$ sudo umount /path/to/local/folder

Using SSHFS with Private Key

For SSH setups that require a Private Key/Identity file, you can use the following:

Terminal
$ sshfs remoteUser@remoteHost:/path/to/remote/folder /path/to/local/folder \
  -o IdentityFile=/path/to/identity/file


# When done:
$ sudo umount /path/to/local/folder

Mounting files as non-sudo user

If you run into the ssh “permissions are too open” error when using an identity file, try running the following:

Terminal
# Make file readable only to you
$ chmod 400 /path/to/identity/file

# Mount
$ sshfs remoteUser@remoteHost:/path/to/remote/folder /path/to/local/folder \
  -o IdentityFile=/path/to/identity/file

# Unmount:
$ sudo umount /path/to/local/folder