As you may know, Hetzner boxes don’t allow an interactive shell. This means that you cannot run rm -rf /dir-to-delete. To empty a remote directory on a Hetzner storage box, you can use rsync with –delete flag as follows:
rsync -avze "ssh -i ~/.ssh/your-ssh-key -p 23" --delete /path/to/empty-dir/ username@your-storage-box-url:/home/remote-dir-to-delete
A couple of things to note:
- Replace your-ssh-key with the name of your ssh key which you have uploaded to your Hetzner storage box
- Create an empty dir and then replace /path/to/empty-dir with the path of the dir you created
- Replace username@your-storage-box-url with the username and url or your Hetzner storage box
- Replace /home/remote-dir-to-delete with the remote path of the dir you’d like to empty on your storage box. E.g if you wanted to empty a dir called mydir, the path would be /home/mydir