Data Transfer/SSHFS

From bwHPC Wiki
< Data Transfer
Revision as of 16:26, 17 June 2026 by K Siegmund (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Sshfs is a network protocol for mounting data. It uses sftp under the hood.

Installation

For the necessary installations follow this link:
How to use SSHFS to Mount Remote Directories over SSH.
a) MacOS after the installation
To enable sshfs on your Mac go to: System Preferences -> General tab -> Allow Extensions button
Then follow the instructions that pop up (make sure that you remember the instructions before shutting down your computer).
b) Linux installation short commands

  • Debian/Ubuntu: apt-get install sshfs
  • CentOS/RedHat: dnf install fuse-sshfs
  • If you want to use /etc/fstab, you can do this with the following entry:
    sshfs#<username>@<hostname>:    <your_local_mountpoint>   fuse   defaults,user,noauto,exec        0       0 

Usage

Caveat: Unmounting

Note that this creates a virtual drive on your system just as if you would plug in an external drive that stays active until you unmount it. Disk mounts happen on a low level of operating systems, so it is important to unmount the virtual drive cleanly whenever possible.

MacOS & Linux:
If the connection to the cluster broke and you want to remount, you often have to use umount first. Try to remember to always unmount first before retrying. Otherwise it can happen that unmounting is not possible anymore by cmd. Usually the error message in this case tells you that the process is currently busy and therefore cannot umount.

You should be able to find the process(es) that use the file system with fuser -m <your_local_mountpoint> and kill/exit the processes that block unmounting or can kill them directly using fuser -k -m <your_local_mountpoint> In case this fails, you may have to restart your computer which automatically unmounts everything.

bash
umount -f <localPath>
# For example
umount -f /Users/<username>/Documents/mounted
# or use
fusermount -u <localPath>

Windows You should be able to click on the drive and choose "eject" or "unmount". If this is not the case, you can use

net use X: /delete

or if this does not work

taskkill /f /im sshfs.exe 

(from: stackoverflow)


Windows

Caution: sshfs on Windows doesn't work with 2FA. An alternative is Rclone with sftp + ssh key.

  1. Go to "This PC" and select "Connect network drive" ("Netzlaufwerk verbinden")
  2. Select a drive (W:) and click on "connect with webpage on which you can save documents and images" (Verbindung mit website herstellen, auf der Sie Dokumente und Bilder speichern können)
  3. Enter the following as address, to connect to the home or root folder:
    \sshfs\<username>@<hostname>/
    
    If you would want to go two folders up, you would add “../../” at the end.

MacOS & Linux

  1. Create an empty directory. The cluster/storage folder is going to be mounted to this directory.
  2. Mount a folder from the cluster/storage:
    # Home folder
    sshfs <username>@<hostname>: <localPath>
    # subfolderX
    sshfs <username>@<hostname>:subfolderX <localPath>