Skip to content

Instantly share code, notes, and snippets.

@artyomLisovskij
Forked from pigeonflight/README.rst
Created April 21, 2020 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artyomLisovskij/1cc2185e819261ba4c7539aa93a66d57 to your computer and use it in GitHub Desktop.
Save artyomLisovskij/1cc2185e819261ba4c7539aa93a66d57 to your computer and use it in GitHub Desktop.
Script to mount hetzner backup space

Setup

All commands here are run as root Install sshfs and autofs :

apt-get update
apt-get install sshfs autofs

Ensure you have an ssh key:

ssh-keygen

export backup_user=uXXXXXXX

have your backup space password ready (you can find it in your hetzner controlpanel for your server). Then run the following command:

bash mount-my-backup-space.sh

You should now be able to access your backup space at /mnt/sshfs/my-backup-space

ssh-keygen -e -f .ssh/id_rsa.pub | grep -v "Comment:" > .ssh/id_rsa_rfc.pub
cat .ssh/id_rsa_rfc.pub >> backup_authorized_keys
# set this to name of your backup user usually something like u432424
# we then send the new key to the backup service
# this is a funny way of sending a command but necessary because
# of lack of shell access to the backup space, probably so people don't
# try to use the backup space to run additional services
echo mkdir .ssh | sftp $backup_user@$backup_user.your-backup.de
# don't worry if "mkdir .ssh" fails, it means it exists already
scp backup_authorized_keys $backup_user@$backup_user.your-backup.de:.ssh/authorized_keys
mkdir -p /mnt/sshfs
mkdir -p /etc/auto.master.d
echo "/mnt/sshfs /etc/auto.sshfs uid=0,gid=0,--timeout=30,--ghost" > /etc/auto.master.d/sshfs.autofs
echo "my-backup-space -fstype=fuse,rw,nodev,nonempty,allow_other,reconnect,max_read=65536 :sshfs\#$backup_user@$backup_user.your-backup.de\:/" > /etc/auto.sshfs
# reload autofs
service autofs reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment