This script is designed to automatically unlock your KeePassXC database upon Windows login using the password stored in the Windows Credential Manager. By utilizing the stored credentials, you can streamline the login process and improve your workflow without compromising security.
To securely store your KeePassXC database password in Windows Credential Manager, follow these steps:
-
Open the Start Menu:
- Click on the Windows icon in the taskbar or press the Windows key on your keyboard.
-
Search for Credential Manager:
- Type "Credential Manager" in the search bar.
-
Launch Credential Manager:
- Click on "Credential Manager" from the search results to open it.
-
Navigate to Windows Credentials:
- In the Credential Manager window, click on "Windows Credentials."
-
Add a New Credential:
- Click on the "Add a generic credential" link.
-
Internet or Network Address:
- In the "Internet or network address" field, enter
KeePassXCPassword.
- In the "Internet or network address" field, enter
-
User Name:
- Leave the "User name" field empty or fill it in with a descriptive name (this field can also be left blank).
-
Password:
- In the "Password" field, enter the password you want to store for your KeePassXC database.
-
Save the Credential:
- Click the "OK" button to save the credential.
-
Check the List of Credentials:
- You should now see
KeePassXCPasswordlisted among your Windows credentials.
- You should now see
-
Confirm the Details:
- You can click on the entry to view or edit the details if needed.
- Ensure that the password entered is accurate, as this will be used by the script to unlock your KeePassXC database.
- Storing your password in Windows Credential Manager helps enhance security by keeping your credentials safe and accessible only by authorized applications.
To use this script, you need to install the CredentialManager PowerShell module, which allows interaction with the Windows Credential Manager. Follow these steps to install the module:
-
Open PowerShell as an administrator:
- Right-click on the PowerShell icon and select "Run as administrator".
-
Install the
CredentialManagermodule by executing the following command:Install-Module -Name CredentialManager -Scope CurrentUser
-
When prompted, confirm the installation by selecting "Yes".
Before executing the install.ps1 script, you need to ensure that the following variables are correctly set in the script:
-
$keepassPath
- This variable should contain the path to the KeePassXC executable. Ensure that the path is correct according to your system setup. The default is set as:
$keepassPath = "C:\Program Files\KeePassXC\KeePassXC.exe"
- This variable should contain the path to the KeePassXC executable. Ensure that the path is correct according to your system setup. The default is set as:
-
$databasePath
- Update this variable with the path to your KeePass database file. The default path is set to:
$databasePath = "G:\Mój dysk\KeePass\Database.kdbx"
- Make sure to adjust this path if your database is located elsewhere.
- Update this variable with the path to your KeePass database file. The default path is set to:
-
$keyFilePath (optional)
- If your database uses an additional key file, set this variable to the full path of that key file:
$keyFilePath = "G:\Mój dysk\KeePass\Keyfile.key"
- Leave this variable empty if you do not use a key file.
- If your database uses an additional key file, set this variable to the full path of that key file:
-
$yubiKeySlot (optional)
- If your database is protected with a physical key like a YubiKey (challenge-response), set this variable to the appropriate slot or slot with serial number:
$yubiKeySlot = "2" # or $yubiKeySlot = "2:1234567"
- Leave this variable empty if you do not use a physical key.
- If your database is protected with a physical key like a YubiKey (challenge-response), set this variable to the appropriate slot or slot with serial number:
To ensure that the install script runs without being blocked by PowerShell's execution policies, you can execute the following command:
powershell -ExecutionPolicy Bypass -File ".\install.ps1"In cases where the automatic startup of the KeePassXC auto-unlock script fails, you can manually trigger it using the Run-KeePassXC-AutoUnlock.bat file. This batch file is designed to execute the PowerShell script keePassXC-AutoUnlock-Login-Windows.ps1 with the necessary execution policy bypass.
To use it:
- Navigate to the directory where you have cloned this repository.
- Double-click
Run-KeePassXC-AutoUnlock.bat.