Blog mount-remote-ssh-folder-arch-linux
linuxJULY 13, 2024

Mounting a Remote SSH Folder on Linux

kraaakilo's avatar

Mounting a Remote SSH Folder on Linux

Hey there! Today, I'm going to show you how I mount a remote SSH folder on my Arch Linux machine. I needed a reliable way to store my Obsidian notes securely and access them from anywhere. This setup allows me to keep my notes on a remote server, ensuring they are always backed up and accessible. It’s pretty straightforward once you get the hang of it. Let’s get started!

Prerequisites

  1. A remote server with SSH access.
  2. SSHFS installed on your local machine.
  3. Proper permissions on both ends.
  4. An SSH key for authentication.

Step 1: Install SSHFS

First things first, let's install SSHFS. Open your terminal and run:

sudo pacman -S sshfs

Step 2: Prepare Your SSH Key

Make sure you have an SSH key set up. If you don't have one yet, create it using:

ssh-keygen -t rsa -b 4096 -C "sampledummy@email.test"

Copy your SSH key to the remote server: In my case i have setup an alias for ssh connection in my ~/.ssh/config file

ssh-copy-id -i ~/.ssh/rsa_key username@remoteserver

Step 3: Create a Mount Point

Next, create a directory on your local machine where you want to mount the remote folder. I like to keep things organized, so I create a folder under /mnt:

sudo mkdir -p /mnt/proxmox

Step 4: Edit the /etc/fstab File

Now, let's edit the /etc/fstab file to automate the mounting process. Open the file in your favorite text editor (I use nvim):

sudo nvim /etc/fstab

Add the following line to the file:

root@192.168.1.10:/mnt /mnt/proxmox fuse.sshfs noauto,x-systemd.automount,_netdev,reconnect,identityfile=/path/to/identity/file/,allow_other,default_permissions 0 0

Breakdown of the /etc/fstab Line

  • root@192.168.1.10:/mnt: Remote server and directory.
  • /mnt/proxmox: Local mount point.
  • fuse.sshfs: Filesystem type.
  • noauto: Do not mount automatically at boot.
  • x-systemd.automount: Use systemd to mount on demand.
  • _netdev: Network device, wait for network to be up.
  • reconnect: Reconnect if the connection is lost.
  • identityfile=/path/to/identity/file/: Path to your SSH key.
  • allow_other: Allow other users to access the mount.
  • default_permissions: Use default permissions.

Step 5: Mount the Remote Folder

Finally, let's mount the remote folder:

sudo mount /mnt/proxmox

And there you have it! Your remote SSH folder is now mounted on your local machine. You can access it just like any other directory.

Troubleshooting Tips

  • If you run into permission issues, make sure your SSH key has the correct permissions.
  • Verify that the remote server is accessible and the SSH service is running.

And that's it! Now you know how to mount a remote SSH folder on your Arch Linux machine. This setup is essential for me because it helps me seamlessly access and save my Obsidian notes on my remote server. By automating the mount process with fstab, I can focus more on my work and less on managing connections.

Let's connect

Stay in the loop with my latest projects and insights! Follow me on Twitter to catch all the updates as they happen. Don't miss out on the journey – let's connect and explore the world of tech together. Click to follow now!