Sign In
Sign In

How To Use SSHFS to Mount Remote File Systems Over SSH

How To Use SSHFS to Mount Remote File Systems Over SSH
Awais Khan
Technical writer
Linux
24.12.2024
Reading time: 6 min

SSHFS is a Linux tool for mounting remote folders over SSH. It allows users to manage network-shared files just like local ones. This tool is secure and efficient, providing seamless management of network shared folders across different environments.

Required Setup

Before you start, ensure you have:

  • Root or sudo permissions.
  • An external server with SSH enabled.
  • An SSH service working on your local machine.

And if you’re looking for a reliable, high-performance, and budget-friendly solution for your workflows, Hostman has you covered with Linux VPS Hosting options, including Debian VPS, Ubuntu VPS, and VPS CentOS.

Using SSHFS

Step 1: Install SSHFS

First, install SSHFS on your local system through the package manager. This tool installation on the other system is not needed.

On Ubuntu/Debian:

sudo apt install sshfs

Image1

On CentOS/RHEL:

sudo yum install sshfs

Step 2: Create a Connection Point

Set up a folder in your home or any desired location. This will act as the connection point for the network shared directory.

sudo mkdir remote_dir

Image3

Step 3: Attach a Directory

Attach the linked folder to the local computer for seamless access. Use the below-given command to perform remote filesystem mounting:

sudo sshfs -o [options] user@host:/remote_path /local_mount

Substitute user with your real remote server’s username, host with the IP address or hostname of the server, and /remote_path with the directory path you want to connect. The [options] include:

  • allow_other: Grants access to other local machine users for accessing the mounted folder.
  • reconnect: Automatically re-establishes the connection in case it drops.
  • IdentityFile=/loc/of/private_key: Specify the location where SSH private key is stored.
  • idmap=user: Aligns the ID of remote user to the local user ID.
  • default_permissions: Applies the remote file system's default permissions.

To connect the linux home folder from 192.X.X.X to /home/ubuntu/remote_dir, utilize:

sudo sshfs -o allow_other,default_permissions linux@192.X.X.X:/home/linux/ /home/ubuntu/remote_dir/

To employ an SSH key found at /home/ubuntu/.ssh/id_rsa, use:

sudo sshfs -o allow_other,default_permissions,IdentityFile=/home/ubuntu/.ssh/id_rsa linux@192.X.X.X:/home/linux/ /home/ubuntu/remote_dir/

Type 'yes' to accept the server’s fingerprint and add it to known hosts.

Image2

Enter the password for authentication. Use the key if set up.

Image5

After verification, the folder will be linked to the local path.

Image4

Step 4: Verification

Create a new folder or file in the attached directory and verify its existence on the external server.

Image7

If the folder or file appears in the external server's directory, the operation is successful. This ensures changes in your local directory are mirrored on the external system.

Image6

If you experience the "Permission denied" error when trying to create or modify an existing file, follow these instructions to resolve it:

  1. Run the ls -l command to view the current permission of files or directory.

  2. Execute the chmod command to modify the permissions.

sudo chmod 644 /path/to/file_or_directory
  1. If the file or directory is owned by another person, run the chown command to change the ownership.

sudo chown your_username  /path/to/file_or_directory

Step 5: Unmounting

Once finished, simply unmount the folder:

sudo umount /remote_directory

Image9

Additional Options

Below are some additional things you can also do: 

Auto-Mounting at Boot

To automatically connect remote filesystem at startup, utilize these steps:

Step 1: Edit fstab

Access the /etc/fstab file with elevated privileges:

sudo nano /etc/fstab

Step 2: Add Entry

Append an entry to the end of the file:

user@remote_host:/remote/directory /local/mount/point fuse.sshfs noauto,x-systemd.automount,_netdev,users,idmap=user,allow_other,reconnect 0 0

Example:

linux@192.X.X.X:/home/linux/ /home/ubuntu/remote_dir fuse.sshfs noauto,x-systemd.automount,_netdev,users,idmap=user,allow_other,reconnect 0 0

Where:

  • noauto: Automatically stops the mount from happening at boot.
  • x-systemd.automount: Uses systemd to dynamically connect the filesystem upon access.
  • _netdev: Indicates that network access is required for the process.
  • users: Grant non-root users the ability to mount and unmount.
  • idmap=user: Associates external user with local one.
  • allow_other: Permits another person from retrieving the connected directory.
  • reconnect: Ensures automatic reconnection in case connection drops.

Step 3: Create a Connection Point

Make sure the local mount point directory exists, and if not, create it:

sudo mkdir -p /home/ubuntu/remote_dir

Step 4: Testing

Test the connectivity:

sudo mount -a

This command initiates the connection of all filesystems listed in /etc/fstab. If no errors arise, the process is successful.

Utilizing SSHFS Without SFTP

SSHFS usually utilizes SFTP for transferring. To bypass this, run:

sshfs -o sftp_server=/usr/lib/openssh/sftp-server user@host:/remote_directory ~/remote_mount

Configuration File

To save commonly used options, create a .sshfs_config file in your home location. This will allow you to store and easily apply your preferred settings.

nano ~/.sshfs_config

Add your options and connect via the configuration file.

sshfs -F ~/.sshfs_config username@remote_host:/remote/directory ~/remote_mount

Resolving Typical Problems

Below are some common problems and solutions.

Connectivity Problems

To ensure seamless connectivity, make certain that SSH service is configured in the correct way on both your local and external systems. Also, check that the service port is open and that your firewall settings allow access, which is crucial for maintaining an uninterrupted connection.

Performance Issues

For better performance, use the -o direct_io and -o cache=yes options.

sshfs -o direct_io -o cache=yes user@host:/remote_directory ~/remote_mount

Connection Reset by Peer

  • Cause: The external SSH server may be down, or there could be network instability.
  • Solution: Verify that the SSH server is operational on the external machine. Ensure a stable network connection for consistent communication.

Permission Denied

  • Cause: The user lacks the required permissions to access the network-shared folder.
  • Solution: Confirm that you have the correct permissions. Proper access rights are essential for successful connection.

Running SSHFS on Windows

To utilize SSHFS for Windows, follow these instructions:

  1. Download and set up SSHFS-Win from this location.

  1. Right-click on This PC and go with the option Map network drive from the context menu:

Image8

  1. Choose an available drive letter from the menu. In the Folder field, input the command as follows:

\\sshfs\user@host\remote_path

Click Finish to complete the mapping process.

Image12

  1. Enter your credentials and provide the required username and password (or SSH key, if configured).

Once connected, access the directory via Windows Explorer.

Image10

Here are the additional options for the sshfs command based on different used cases:

  • sshfs: Integrates the remote home directory locally.
  • sshfs.r: Links to the remote server's root directory.
  • sshfs.k: Uses [local-user]/.ssh/id_rsa to map the remote home directory.
  • sshfs.kr: Utilizes a locally stored SSH key to access the root directory.

When finished, right-click the network drive and choose Disconnect to detach the directory.

Image11

Conclusion

SSHFS provides an efficient and secure method for mounting remote file systems through SSH. This guide helps you set up and use this tool to improve file management on Linux systems. Whether performing the SSHFS mount as root, avoiding SFTP, or utilizing configuration files, this tool offers flexibility and control for various scenarios.

Linux
24.12.2024
Reading time: 6 min

Similar

Linux

Creating Symbolic Links in Linux: A Step-by-Step Tutorial

Symlinks, also known as symbolic links, are like shortcuts in the Linux world. They allow you to create a new name (or link) that points to another file, directory, or any object within the file system. Their primary advantage lies in reducing redundancy by avoiding the need for multiple copies of the same file. When you have a symlink, changes made to the original file reflect across all its symbolic links. This eliminates the hassle of updating numerous copies individually. Additionally, symlinks offer a flexible way to manage access permissions. For instance, different users with directories pointing to subsets of files can limit visibility beyond what standard file system permissions allow. In essence, symlinks are indispensable for efficient file management and organization, streamlining updates and access control in complex systems. Prerequisites To follow this tutorial, you will need: A cloud server, virtual machine or computer running a Linux operating system. On Hostman, you can deploy a server with Ubuntu, CentOS or Debian in under a minute. Creating Symbolic Links with the ln Command The ln command is used to create symbolic links in Linux. Follow these steps: Open a terminal window. Navigate to the directory where you want to create the symbolic link. Use the following command syntax to create a symlink: ln -s /path/to/source /path/to/symlink Replace /path/to/source with the actual path of the file or directory you want to link, and /path/to/symlink with the desired name/location of the symlink. Understanding the ln Command Options The ln command offers various options to customize symlink creation:  -s: Creates a symbolic link.  -f: Overwrites an existing symlink.  -n: Treats symlink targets as normal files. Explore these options based on your linking needs. Creating Symbolic Links to Files To create a symlink to a file, use the ln command with the -s option. Here's an example of how you can create a symbolic link to a file using the ln command. The command below creates a symbolic link named symlink_file in the current directory, pointing to the file /path/to/file: ln -s /path/to/file /path/to/symlink_file Replace /path/to/file with the actual file path and /path/to/symlink_file with the desired symlink name. In this example, the file path is absolute. You can also create a symbolic link with a relative path. However, keep in mind that for the symlink to work correctly, anything accessing it must first set the correct working directory, or the link may appear broken. Creating Symbolic Links to Directories You can use the ln command to create a symbolic link that points to a directory. For instance, the command below creates a symbolic link called symlink_directory in the current directory, which points to the directory /path/to/directory: ln -s /path/to/directory /path/to/symlink_directory This command creates a symbolic link named symlink_directory in your current location, linking it to the /path/to/directory directory. Forcefully overwrite a symbolic link You can use the -f flag with the ln command. For example, if the path in a symlink is incorrect due to a typo or if the target has moved, you can update the link like this: ln -sf /path/to/new-reference-dir symlink_directory Using the -f flag ensures that the old symlink's contents are replaced with the new target. It also automatically removes any conflicting files or symlinks if there's a conflict. If you attempt to create a symlink without the -f flag and the symlink name is already in use, the command will fail. Verifying Symbolic Links You can display the contents of a symlink using the ls -l command in Linux: ls -l symlink_directory The output will show the symlink and its target: symlink_file -> /path/to/reference_file Here, symlink_file is the name of the symlink, and it points to the file /path/to/reference_file. ls -l /path/to/symlink The output will show the symlink and its target. Symbolic Link Best Practices Use descriptive names for symbolic links. Avoid circular links to prevent system confusion. Update symlinks if the target's location changes. Use Cases for Symbolic Links Managing Configuration Files: Linking configuration files across systems. Version Control: Symbolic linking common libraries for development projects. Data Backup: Creating symbolic links to backup directories. Potential Pitfalls and Troubleshooting Permission Issues: Ensure proper permissions for source and symlink. Broken Links: Update symlinks if target files are moved or deleted. Cross-Filesystem Links: Symlinks may not work across different filesystems. Conclusion Symlinks are valuable for streamlining file management and system upkeep. They simplify updates across multiple applications sharing a common file, reducing maintenance complexity. They also offer an alternative to directories like /etc, often requiring root access for file modifications. Developers find symlinks useful for transitioning between local testing files and production versions seamlessly. By following this tutorial, you've mastered the art of creating symbolic links in Linux. Leverage symlinks for efficient file management and customization. By the way, with Hostman, you can run your workloads on efficient NL VPS that support low latency for EU-based users. Check this out, we have plenty of budget VPS hosting options for your projects. Frequently Asked Questions (FAQ) How do you create a symbolic link in Linux?  Use the ln command with the -s flag. The syntax is ln -s [path_to_target] [path_to_link]. For example: ln -s /var/www/html/mysite ~/mysite-shortcut. What is an example of a symlink?  A desktop shortcut is the most common example. It is a small file that points to a program or document stored elsewhere on your drive, allowing you to open it without moving the original file. How do I find symbolic links in Ubuntu?  To see links in your current directory, run ls -la and look for files marked with an l permission (e.g., lrwxrwxrwx). To search for all symlinks in a directory and its subfolders, use find . -type l. How do I remove a symbolic link?  You can remove a symlink just like a regular file using rm [link_name] or unlink [link_name]. This deletes the link but leaves the original file untouched. What is the difference between a hard link and a symbolic (soft) link?  A symbolic link points to the location of a file (like a shortcut). If the original file is deleted, the link breaks. A hard link points to the actual data on the disk; even if you delete the original file name, the data remains accessible through the hard link.
19 January 2026 · 6 min to read
Linux

Linux Keyboard Shortcuts: Top Combinations for Users

Keyboard shortcuts in Linux are a great tool that can help you work more efficiently. Instead of using the mouse and navigating the menus, you can often press a couple of buttons to get you to the same result much quicker. Linux operating systems support a wide range of these shortcuts, or hotkeys. It’s important to note that each OS can have specific hotkeys that might not work in other distributions. However, you can fix that as users can add new or modify existing combinations in their system settings. Choose your server now! In this article, we will cover universal key combinations that are universal across different desktop environments. Most of the Linux hotkeys we examine are focused on working with the terminal. The commands in this article sometimes use the Super key, which corresponds to the Windows key in Windows OS or the Cmd key in macOS. For example, the shortcut to switch keyboard layouts Super + Space in Linux is similar to Windows + Space or Cmd + Space. Basic Linux Shortcuts Let’s start with basic general-purpose shortcuts. They help perform repetitive tasks more quickly. Alt + Tab or Super + Tab: Switches between windows. Similar to the function in Windows and other OSes. Super + Space: Switches between multiple keyboard layouts. Super + A: Opens the applications menu (usually located in the bottom left corner). F2: Used to rename files. Navigate to the file, click it once, then press F2 to rename. Ctrl + Alt + T: One of the most important and popular Linux shortcuts that opens the terminal window. Alt + F2: Opens a command prompt window in the center of the screen, where you can run a command or open a program. Super + D: Minimizes all windows to show the desktop. Ctrl + Alt + Del: Brings up a prompt with “Cancel” and “Log Out” options. The system logs out automatically if no selection is made within 60 seconds. These combinations help any specialist work more efficiently in Linux. But let’s move on to the more useful terminal-related hotkeys. Linux Terminal Shortcuts The terminal in Linux is the primary tool for interacting with the command shell. Below are terminal hotkeys that will help you work more efficiently. Terminal Window Management These shortcuts help open, switch, and close terminal tabs and windows quickly: Ctrl + Shift + Q: Completely closes the terminal window. Ctrl + Shift + T: Opens a new terminal tab. Ctrl + Shift + W: Closes the current terminal tab (or window if only one tab is open). Ctrl + Shift + D: Detaches the terminal tab into a separate window. Ctrl + PgUp / PgDown: Switches between terminal tabs (previous/next). Cursor Movement in a Line Linux users primarily use the keyboard in the terminal. To avoid switching to the mouse, here are some shortcuts for faster cursor navigation: Ctrl + A (or Home): Moves the cursor to the beginning of the line. Ctrl + E (or End): Moves the cursor to the end of the line. Ctrl + XX: Quickly moves the cursor to the beginning of the line; using it again returns it to the original position. Ctrl + → / ← or Alt + F / B: The first pair moves the cursor one word forward or backward. The second pair does the same using the Alt key. Input and Editing In addition to quickly moving the cursor along the line, you can also simplify input and editing of commands.  TAB: One of the main hotkeys in the Linux terminal, used for auto-completing commands or file paths. Pressing once completes the command; pressing twice suggests multiple completion options if available. Ctrl + T: Swaps the last two characters before the cursor. Alt + T: Similar to the previous shortcut but swaps the last two words before the cursor. Alt + Backspace: Deletes the word before the cursor. Alt + D: Deletes all characters after the cursor up to the next space. Alt + U / Alt + L: The first changes all characters to the right of the cursor to uppercase; the second to lowercase. Clipboard Operations These shortcuts allow interaction with the clipboard in the terminal: copying, cutting, or pasting parts of a line or the entire line. Ctrl + W: Deletes the word before the cursor. Ctrl + U: Deletes everything from the cursor to the beginning of the line. Ctrl + K: Deletes everything from the cursor to the end of the line. Ctrl + Y: Pastes the last deleted text from the clipboard using one of the three commands above. Command History Navigation Hotkeys also help interact with the command history in the terminal. This is useful when searching for previously used commands. To view the list of executed commands, use: history To quickly find and execute a previously used command, use the shortcuts below: Ctrl + R: Opens a search prompt to find a previously used command. Press Enter to run it, or Esc to edit or exit. Ctrl + O: Executes the command found using the shortcut above. Alt + <: Loads the first command from the command history. Screen Output Management The following shortcuts control the amount of information displayed in the terminal window and help focus on specific data even during a running process. Ctrl + C: Sends the SIGINT signal to the active process, immediately interrupting it. Ctrl + D: An alternative to exit, used to close the terminal. Often used in SSH sessions to disconnect from a remote host. Ctrl + Z: Suspends the active process and sends it to the background. Use the fg command to bring it back. Use jobs to list background processes. Ctrl + L: An alternative to the clear command, clears the terminal screen. Ctrl + S / Ctrl + Q: Ctrl + S pauses the terminal output; Ctrl + Q resumes it. Useful for stopping the screen output temporarily to examine or copy information. Adding and Modifying Hotkeys A Linux user may find that some combinations do not work or are missing entirely. Hotkeys may differ depending on the distribution as each system includes a default list of predefined shortcuts. However, in most Linux environments, users can create new shortcuts or modify existing ones.  Use Super + A to open the application menu. Use the search bar to find and open Settings. In the opened window, find and go to the Devices tab. Go to the Keyboard section. On the right side, a list of default hotkeys will appear. Click on any command to open the editing window and assign a new shortcut. If the desired command is not listed, you can add a custom one by clicking the + at the bottom. Enter its name, the command to execute, and the key combination. Choose your server now! Conclusion This article reviewed the main Linux hotkeys that simplify and speed up user workflow. It’s important to note that this is not a complete list. In addition to those listed, there are other combinations that cover different functionalities in Linux distributions. And if you’re looking for a reliable, high-performance, and budget-friendly solution for your workflows, Hostman has you covered with Linux VPS Hosting options, including Debian VPS, Ubuntu VPS, and VPS CentOS. Frequently Asked Questions (FAQ) What are the common shortcut keys for Linux?  While they vary by desktop environment (GNOME, KDE, etc.), standard global shortcuts include: Ctrl+Alt+T: Open a new Terminal window. Alt+Tab: Switch between open applications. Super Key (Windows Key): Open the Activities overview or Application menu. Alt+F4: Close the current window. What are the Linux shortcut keys for the terminal?  Terminal shortcuts differ from standard text editors. Key commands include: Ctrl+Shift+C / V: Copy and Paste text (standard Ctrl+C/V won't work). Ctrl+C: Interrupt (kill) the currently running process. Ctrl+L: Clear the terminal screen. Ctrl+A / Ctrl+E: Jump the cursor to the start or end of the line. How to set keyboard shortcuts in Linux?  Open your system Settings and select Keyboard. Scroll to the "Keyboard Shortcuts" section (sometimes under "View and Customize Shortcuts"). Here you can modify existing keys or add a custom shortcut by defining a command and pressing the desired key combination. How to use shortcuts on Linux?  Simply press the modifier keys (like Ctrl, Alt, or Super) and the action key simultaneously. Note that Linux shortcuts are case-sensitive regarding the Shift key; for example, Ctrl+c is different from Ctrl+Shift+C.
16 January 2026 · 7 min to read
Linux

How to Mount an SMB Share in Linux

The Server Message Block (SMB) protocol facilitates network file sharing, allowing applications to read and write to files and request services from server programs. This protocol is pivotal for seamless communication between different devices in a network, particularly in mixed OS environments like Windows and Linux. Users can access files on a Windows server or any SMB-enabled device straight from their Linux workstation by mounting an SMB share. In order to ensure seamless file sharing and network connectivity, this tutorial will walk you through the process of mounting an SMB share on Linux. Linux terminal is important tool to install SMB Share in Linux And if you’re looking for a reliable, high-performance, and budget-friendly solution for your workflows, Hostman has you covered with Linux VPS Hosting options, including Debian VPS, Ubuntu VPS, and VPS CentOS. Choose your server now! Prerequisites for Mounting SMB Shares Before mounting an SMB share, ensure the following prerequisites are met: A Linux system, such as a Hostman cheap cloud server, with root or sudo privileges. The cifs-utils package installed on your Linux system. Access credentials (username and password) for the SMB share. Network connectivity between your Linux system and the SMB server. Installing Necessary Packages The cifs-utils package is essential for mounting SMB shares on Linux. Additionally, the psmisc package provides the fuser command, which helps manage and monitor file usage. Update Package List and Upgrade System First, update your package list and upgrade your system: sudo apt update Install cifs-utils and psmisc Install the necessary packages: sudo apt install cifs-utils psmisc Verify Installation Verify the installation of cifs-utils and availability of the fuser command: mount -t cifsfuser Finding SMB Share Details Get the SMB share information, such as the share name and the server name or IP address. You may need to examine the server setup or speak with your network administrator. Example: Server: smbserver.example.com Share: sharedfolder Mounting SMB Shares Using the mount Command To mount the SMB share, use the mount command with the -t cifs option, specifying the SMB protocol. Create a directory to serve as the mount point: sudo mkdir /mnt/smb_share Mount the SMB share using the following command: sudo mount -t cifs -o username=your_username,password=your_password //192.0.2.17/SharedFiles /mnt/smb_share Replace your_username and your_password with your actual username and password. Ensure /mnt/smb_share is an existing directory. Verifying the Mount To confirm that the SMB share is successfully mounted, use the mount command: mount -t cifs Navigate to the mount point and list the files: cd /mnt/smb_sharels Creating a Credentials File Make a credentials file so you don't have to enter your credentials every time. This file has to be guarded and hidden. Use a text editor to create the file: nano ~/.smbcredentials Add the following content, replacing with your actual credentials: username=your_usernamepassword=your_password Set appropriate permissions for the file: sudo chown your_username: ~/.smbcredentialssudo chmod 600 ~/.smbcredentials Mount Using the Credentials File Mount the SMB share using the credentials file: sudo mount -t cifs -o credentials=~/.smbcredentials //192.168.2.12/SharedFiles /mnt/smb_share Quick example of how SMB Shared is mounted in Linux terminal Automating SMB Share Mounts To automate the mounting process, add an entry to the /etc/fstab file. This will ensure the SMB share is mounted at boot. 1. Open /etc/fstab for editing: sudo nano /etc/fstab 2. Add the following line: //smbserver.example.com/sharedfolder /mnt/smbshare cifs username=johndoe,password=securepassword,iocharset=utf8,sec=ntlm 0 0 3. Save and close the file. 4. Test the fstab entry: sudo mount -a Ensure no errors are displayed. Troubleshooting Common Issues Permission Denied Check your credentials and permissions on the SMB server. No Such File or Directory Ensure the server IP, share path, and mount point are correct. Mount Error 13 = Permission Denied Double-check your username and password. Mount Error 112 = Host is Down Verify network connectivity and server availability. Unmounting an SMB Share To unmount the SMB share, use the umount command followed by the mount point: sudo umount /mnt/smb_share Choose your server now! Conclusion Mounting an SMB share in Linux is a straightforward process that enhances file sharing capabilities across different operating systems. By following this tutorial, you can efficiently set up and troubleshoot SMB share mounts, facilitating seamless network communication and file access. Don't forget to check how to configure server image on Lunix! Frequently Asked Questions (FAQ) How do I mount an SMB share in Linux manually?  Use the mount command with the cifs type. The syntax is: sudo mount -t cifs -o username=[user] //server/share /mnt/local_mountpoint You will be prompted to enter the password for the SMB user. How do I mount a Samba share in Linux permanently?  To mount a share automatically at boot, add an entry to your /etc/fstab file. It generally looks like this: //server/share /mnt/point cifs username=user,password=pass 0 0 Note: For security, it is better to use a credentials file instead of putting the password directly in fstab. How do I mount an SMB share in CentOS/RHEL?  First, ensure the necessary utilities are installed by running sudo dnf install cifs-utils. Once installed, the mount process is the same as other distributions: sudo mount -t cifs -o username=[user] //server/share /mnt/point What do I do if I get a "wrong fs type" error?  This usually means the helper utilities are missing. On Ubuntu/Debian, run sudo apt install cifs-utils. On CentOS/Fedora, run sudo dnf install cifs-utils. How do I unmount the share when I'm done?  Use the umount command followed by the local directory: sudo umount /mnt/local_mountpoint
14 January 2026 · 5 min to read

Do you have questions,
comments, or concerns?

Our professionals are available to assist you at any moment,
whether you need help or are just unsure of where to start.
Email us
Hostman's Support