Introduction to keepass

Everyone should use password managers, because remembering unique passwords is difficult. There are many great password FOSS password managers such as bitwarden, keepass, keepassxc etc. I wouldnt recommend using bitwarden because its cloud based, Your password database is being stored in cloud, and it makes me really paranoid. because there are thousands of users using it, so a lot of hackers trying to hack bitwarden’s server. bitwarden allows you to self-host it, so you can host it in your own server.

But you know, your boy is still paranoid. So i will go with keepassxc because its completely offlilne. You can read the installation instructions and read more about it on keepassxc.org However, we are going focus more about how to sync the password database created from keepassxc on your desktop and cellphone(android).

After you are done installing keepassxc on your desktop, install keepassdx on your cellphone, To access your encrypted password database from your cellphone.

Sync the database between both devices.

  1. Install rsync and ssh(obviously…) on your desktop.
  2. Install termux on your cellphone.
  3. install rsync & openssh on termux by running pkg install openssh rsync
  4. start ssh server on termux by running sshd
  5. get your local ip adress of your cellphone by running ifconfig

Once you are done with that, go to the terminal on your desktop and run this command:

rsync -vrP --delete --rsh='ssh -p 8022' ~/passdb/on/desktop.kbdx username@ip:passdb/on/cellphone.kbdx 

here i specify the port with --rsh='ssh -p 8022' because specifying it with --port flag didng work for me. repace your username with your username and local ip adress of termux in username@ip. and repace the paths in the commands to where your password database is stored in your desktop and cellphone. and here we go, it will sync the database.

However, i wanted to go further and make it a bit automaticish, so i ended up with this script.

#!/bin/sh
# paths of database file locations in android and desktop
anpath="storage/shared/path/to/pass-database.kdbx"
deskpath="path/to/pass-database.kdbx" 

# getting last modified date
desktop=$(stat -c%Y $deskpath)
android=$(ssh android -t stat -c%Y $anpath)

# syncing the database between both devices by calculating
# in which device the password database was last modified.
# not syncing anything if there was no change.
if [ $android -lt $desktop ]; then
  echo "transferring from desktop to android"
  rsync -vrtP $deskpath android:$anpath 
elif [ $desktop -lt $android ]; then
  echo "transferring from android to desktop"
  rsync -vrtP android:$anpath $deskpath
elif [ $desktop -eq $android ]; then
  echo "nothing was modified, not syncing"
fi

When i run this script, it will check in which device i had the password database last modified, and sync the password databse from desktop to cellphone if it was last modified on my desktop computer and vice versa.

Thank you for reading my blog with bajillions of spelling & grammar mistakes.