Mount a Hetzner Storage Box on Linux (CIFS and SSHFS)
Mount a Hetzner Storage Box sub-account on Linux with CIFS (fstab included) or SSHFS, then unmount it.
A Hetzner Storage Box can be mounted on Linux with CIFS (SMB) or with SSHFS. In both cases, first create a sub-account with its share name in the Storage Box settings: the share name is the path used in the mount commands.
In the examples, uXXXXXX is the account identifier, <password> the password and <port> the SSH/SFTP port.
SFTP access and SSH key
sftp -P <port> uXXXXXX-sub1@uXXXXXX.your-storagebox.de
ssh-copy-id -p <port> -s uXXXXXX-sub1@uXXXXXX.your-storagebox.de
CIFS mount
Install the CIFS client, then mount the share on an existing folder:
sudo pacman -S cifs-utils
sudo mkdir -p /mnt/storagebox
Mount with read and write access for all users:
sudo mount.cifs -o seal,user=uXXXXXX-sub1,password=<password>,file_mode=0775,dir_mode=0775 //uXXXXXX-sub1.your-storagebox.de/uXXXXXX-sub1 /mnt/storagebox
Mount for the current user:
sudo mount -t cifs -o username=uXXXXXX-sub1,password=<password>,uid=$(id -u),gid=$(id -g) //uXXXXXX-sub1.your-storagebox.de/uXXXXXX-sub1 /mnt/storagebox
In some cases, add forceuid,forcegid to the option list:
sudo mount -t cifs -o username=uXXXXXX-sub1,password=<password>,uid=$(id -u),gid=$(id -g),forceuid,forcegid //uXXXXXX-sub1.your-storagebox.de/uXXXXXX-sub1 /mnt/storagebox
Options such as password= end up in the shell history and in the process list. For a permanent mount, use a credentials file.
Automatic mount with fstab
Create a credentials file with these two lines:
username=uXXXXXX-sub1
password=<password>
Then add this line to /etc/fstab:
//uXXXXXX-sub1.your-storagebox.de/uXXXXXX-sub1 /mnt/storagebox cifs iocharset=utf8,rw,credentials=/etc/backup-credentials.txt,file_mode=0777,dir_mode=0777,seal 0 0
Speed test
sudo dd if=/dev/zero of=/mnt/storagebox/test1.img bs=1G count=20
Then delete the test file: sudo rm /mnt/storagebox/test1.img.
Mount with SSHFS
Install SSHFS, create the mount point and give it to your user:
sudo pacman -S sshfs
sudo mkdir -p /mnt/storagebox
sudo chown $USER:$USER /mnt/storagebox
Simple mount:
sshfs -p <port> user@example.com:/home ~/mnt/storagebox
Mount with automatic reconnection:
sshfs -p <port> \
-o reconnect \
-o ServerAliveInterval=15 \
-o ServerAliveCountMax=3 \
-o idmap=user \
user@example.com:/home \
~/mnt/storagebox
Mount with an SSH key:
sshfs -p <port> \
-o IdentityFile=~/.ssh/id_ed25519 \
-o reconnect \
-o ServerAliveInterval=15 \
-o ServerAliveCountMax=3 \
-o idmap=user \
user@example.com:/home \
~/mnt/storagebox
Unmount
fusermount3 -u ~/mnt/storagebox # SSHFS
sudo umount /mnt/storagebox # CIFS