Combination of Cryptsetup+Zenity+Bash to created an encrypted Vault , with some extra perks !!
There is nothing to configure as of now except
- MAX_VAULT_SIZE by default on line #6 of the file, it's 30 ( as in 30GB), you can change it to whatever you seem fit
- VAULT_FOLDER by default on line #7 it's .vaults which equated to
/home/user/.vaults
, to change it to/home/user/secret/whatever
change line #7 to VAULT_FOLDER="secret/whatever" , make sure folder namewhatever
doesn't exist
- Easy to implement, doesn't require any other program which already doesn't come installed on many distro except zenity
- Here my "Homework" vault is 20GB (which can be extended to maximum depending upon MAX_VAULT_SIZE) If i have to backup it, I need to copy just 1 file which is 20GB, in contrast to gocryptfs where there are so many files and it slows down my backup speed.
- Every vault is secured with a password, you lose it and you lose the vault :"(
- If gocryptfs/any other encrypted software works for you, then don't fix what isn't broke ( although would love to see people trying this out)
- Can't decrease the size of vault, only can increase it ( but there is a workaround )
-
Always your first prompt! Enter your sudo password. Why? Requires access to /dev/mapper to mount devices, you will be asked for sudo once during whole script lifecycle , to avoid any annoyance <3
-
What should script do next?
- If VAULT_FOLDER was not present , You can choose how to create vault -> Using Password or Keyfile
- If VAULT_FOLDER was present, and no vaults were found ( because you deleted it), if pressed yes, it will give prompt as above
- If VAULT_FOLDER was present, and there are more than 0 vaults (vaults end with .img) it asks you to choose action for certain vault, check Understanding default prompt
-
Exit And Close -> Script will exit , and close all vaults ( Pressing Esc button would do same)
-
Exit and Wait -> Script will wait in background .
-
to make it exit
echo closeall >> /home/$USER/<vault_folder>/pipe/m_pipe
defaultecho closeall >> /home/$USER/.vaults/pipe/m_pipe
-
to show default prompt again
echo okay >> /home/$USER/<vault_folder>/pipe/m_pipe
defaultecho closeall >> /home/$USER/.vaults/pipe/m_pipe
-
-
Create New -> Create new vault
-
Okay button -> Takes input of Action and Vault, if no valid Action/Vault is provided, gives error
- Open ->
- If Keyfile is disabled in "Modify Passowrd" section, Or if vault was created with password Asks for password of said vault and mounts it in VAULT_FOLDER/VAULT_NAME.data, and then xdg-open it
- If Keyfile is enabled in "Modify Passowrd" section, Or if vault was created with keyfile Asks for user to select a keyfile and mount vault in VAULT_FOLDER/VAULT_NAME.data, and then xdg-open it
- Close -> If vault is open then close it
- Rename -> Rename Your vault
- Modify Passowrd -> It deserve a section of it's own
- Delete -> Close vault if opened and then proceed to delete it
- Extend -> Show a scale between current SIZE of vault and MAX_VAULT_SIZE , ask user to choose
LUKS provide keyslots to add Passphrases which can come from 2 source
- A password
- A keyfile
LUKS internally doesn't discriminate between these 2, but gives user choice to use whatever seems fit Opening this section you see either of these 2 prompts
- Enable Keyfile button -> Enable keyfile as default vault opening behaviour for selected vault ( If you don't have keyfile added add it first)
- Disable Keyfile button -> Disable keyfile as default vault opening behaviour for selected vault ( If you don't have password added add it first)
- Enable AutoOpen Keyfile button -> Select Keyfile to be used for AutoOpen of Vault( Vault with AutoOpen if that keyfile is present at that location)
- Disable AutoOpen Keyfile button -> Disable Keyfile for Auto Opening of Vault.
In either of above cases you will prompt informing you to add password/keyfile, no data will be lost in enabling or disabling them, it's just default way to handle it you can come back and toggle it back to what you want.
Coming to options
- Add Passowrd -> Password can be added by unlocking the vault using default unlock method and then entering a new Passowrd
- Add Keyfile -> Keyfile can be added by unlocking the vault using default unlock method and then selecting a new keyfile
- Change Password -> Password can be changed by unlocking the vault using any added password to be changed and then entering new password
- Change Keyfile (Only shown if you have enabled keyfile)-> Keyfile can be changed by unlocking the vault using another keyfile to be removed and then selecting a new keyfile
- Remove Password -> Password can be REMOVED by unlocking the vault using password to be removed, IF YOU HAVE NO OTHER PASSWORD OR KEYFILE ADDED, YOU LOSE ALL DATA
- Remove Keyfile (Only shown if you have enabled keyfile)-> Keyfile can be REMOVED by unlocking the vault using keyfile to be removed,IF YOU HAVE NO OTHER PASSWORD OR KEYFILE ADDED, YOU LOSE ALL DATA
- I ran bash_vault.sh from Terminal, What if Ctrl+C it, Do Vault Remain Open?? What happens?
No, signal like SIGINT is trapped and is used to close all vaults before exiting. - I am copying data to vault and i force closed it, what happens to my data?
Depends on resilience of ext4 itself - I like how it works but my work is around one vault only, I don't need many :"(
This is where power of scripting comes in , and you can use keybinding for that. For example in following script you can toggle mount by running it#!/bin/bash VAULT="testing.img" # Remember to put .img here at end, Set your default vault SCRIPT_LOCATION="/home/$USER/bash_vault/bash_vault.sh" #Location of your bash_vault script VAULT_FOLDER=".vaults" #Change it only if you have changed default in script USER_R=$USER FOLDER="/home/$USER/$VAULT_FOLDER" PIPE="$FOLDER/pipe/m_pipe" V_PIPE="$FOLDER/pipe/$VAULT" if [ -p $V_PIPE ]; then echo "Closing vault" echo close >> $V_PIPE else PASS=$(zenity --password --title="Enter Sudo Password") echo $PASS | sudo -E -S $SCRIPT_LOCATION $USER_R $VAULT fi
Right-Click on these gif and click "Open Image in New tab" to view them properly
- Creating a new vault , and you can see force exit will close all mounts ( and so will rebooting your system)
- Extending the newly created vault from 1GB to 5GB
- Closing the vaults using script or zenity window
- Demonstration of my setup where bash_vault is bound to ALT+SHIFT+V
sh -c "~/bash_vault/bash_vault.sh"
- Demonstration of script mentioned in What if section, which toggles mount of
testing.img
Vault on my machine