I was looking for a way to locally encrypt my Obsidian Vault in a simple, but secure way.
None of the available solutions where suited for my needs, so I came up with my own solution, heavily inspired by this blog article.
Prerequisites:
- basic technical and terminal knowledge
Step 1
Creating a encrypted volume
- Open Disk Utility
-
File β New Image β Blank Image
orcmd + N
- Give it a name
- Select a size that will suit your needs (for me 100 mb are more than enough)
- Under encryption select 256-bit-aes and insert a secure password
- Leave everything else as it is
Now you have a .dmg
that needs a password to be mounted
Creating shortcut to mount the encrypted volume and open Obsidian
- Open your preferred text editor
- Create a file that has
.command
as extension - Insert the following code and save
#!/bin/bash
echo 'Mounting the volume'
hdiutil attach ~/Path/to/vault.dmg #has to be full path
echo 'Launching Obsidian...'
open -a "Obsidian"
- Make it executable with
chmod +x script.command
When double-clicked, or executed, the script opens a terminal window asking for the password of your vault
Now just select the volume as your vault and Obsidian will remember it (given it is mounted)
Adjustments
After executing the .command the terminal window remains open and it can be annoying. Uou can modify this behaviour by:
- Open your terminal.app
- Go to
Preferences β Profiles β <the profile you are using> β shell
- Set
When the shell exits:
toClose the window
- Now after executing the .command the terminal window will close
Other
This set-up is MacOS specific but can be easily adjusted to work with other setups and operating systems.