Note
This guide assumes that you are using the KDE Plasma desktop environment.
KDE Wallet Manager is a tool to manage passwords on the KDE Plasma system. By using the KWallet subsystem it not only allows you to keep your own secrets but also to access and manage the passwords of every application that integrates with KWallet.
This details how to create and setup a KDE Wallet and use it by default.
- Using the KDE Wallet to store ssh key passphrases
- Store GPG key passphrases
- How to get gpg-agent to choose an appropriate variant of the pinentry program?
- environment.d
-
Install the
kwalletmanager
package usingyay
to easily configure our KDE Wallet(s).[!NOTE]
This will add a KDE Wallet section to our System Settings application. -
Launch the System Settings application.
-
Under the Security & Privacy group, expand the KDE Wallet section.
-
In the KDE Wallet page, in the Wallet Preferences tab, check the Enable the KDE wallet subsystem box.
-
Under the Automatic Wallet Selection section, click the New button corresponding to the Select wallet to use as default option.
-
Enter a name for the wallet (i.e.
kdewallet
) and click the OK button.[!NOTE]
If you wish to enable wallet auto unlock, you are required to set its name tokdewallet
. -
Select one of the two KDE Wallet type options:
- Classic, blowfish encrypted file (Recommended)
- Use GPG encryption, for better protection
Click the Next button.
-
If you choose to use Blowfish, enter a password but with some considerations depending on your desktop autologin and wallet auto unlock choice:
- To enable desktop autologin and wallet auto unlock: Set an empty password
- To enable desktop autologin but not wallet auto unlock: Set any secure password
- To enable wallet auto unlock but not desktop autologin: Set the same password as your user password
Click the OK button.
-
If you chose to use GPG, select an existing trusted key in the list. If none exists, create a new GPG key and return to this step.
-
Click the Finish button.
-
If prompted to enter the passphrase of your chosen GPG key, enter it and select the OK button.
-
Back in the Automatic Wallet Selection section, expand the Select wallet to use as default dropdown and select the wallet you just created.
-
Under the Secret Service section, check the Use KWallet for the Secret Service Interface box.
-
(Optional) Navigate to the Access Control tab and check the Prompt when an application accesses a wallet box.
-
Click the Apply button at the bottom right.
-
If prompted to authenticate, enter your user credentials and click the OK button.
This describes how to use KDE Wallet to store SSH key passphrases:
-
Install the
ksshaskpass
package usingyay
. -
Create an
environment.d
directory if it does not yet exist:mkdir -p ~/.config/environment.d
-
Create an
environment.d
file namedssh_askpass.conf
:nano ~/.config/environment.d/ssh_askpass.conf
Add the following values to the file and save it:
SSH_ASKPASS=/usr/bin/ksshaskpass SSH_ASKPASS_REQUIRE=prefer
-
(Optional) As it is, this will utilise the KDE Wallet to get the passphrase for the SSH key. However, this is also true even when the user has no access to a graphical session (i.e. in a remote SSH session).
To solve this, add the following logic to your default shell profile (i.e.
fish
):set -x SSH_ASKPASS_REQUIRE (set -q SSH_CONNECTION; and not set -q DISPLAY; and echo never; or echo prefer)
If your default shell profile is
bash
, add the following line instead:export SSH_ASKPASS_REQUIRE=$(if [[ -n ${SSH_CONNECTION} && -z ${DISPLAY} ]]; then echo "never"; else echo "prefer"; fi)
[!IMPORTANT]
This logic will need to be reimplemented and adapted if the user uses a different default shell than any of the earlier examples (i.e.zsh
).This sets the value of
SSH_ASKPASS_REQUIRE
tonever
when the user is logged in remotely via SSH and does not have access to a graphical session.
This describes how to use KDE Wallet to store GPG key passphrases:
-
Install the
kwalletcli
package usingyay
. -
Update the GPG agent configuration file with the following value:
pinentry-program /usr/bin/pinentry-kwallet
-
(Optional) As it is, this will utilise the KDE Wallet to get the passphrase for the GPG key. However, this is also true even when the user has no access to a graphical session (i.e. in a remote SSH session).
To solve this:
-
Write a script to determine the
pinentry
program to use in your path (i.e.~/.local/bin/pinentry-auto
):nano ~/.local/bin/pinentry-auto
Add the following content to the file and save the script:
#!/bin/sh # reference: https://stackoverflow.com/a/77564644 set -eu GRAPHICAL_PINENTRY=$(which pinentry-kwallet) TERMINAL_PINENTRY=$(which pinentry-curses) if [ -z "${SSH_CONNECTION-}" ] && [ -n "${DISPLAY-}" ]; then exec "${GRAPHICAL_PINENTRY}" "${@}" else exec "${TERMINAL_PINENTRY}" "${@}" fi
-
Update the GPG agent configuration file by setting
pinentry-program
to the script you had written (i.e.~/.local/bin/pinentry-auto
):pinentry-program ~/.local/bin/pinentry-auto
This tells GPG to use the script to determine how to get the GPG passphrase - namely,
pinentry-curses
when the user is logged in remotely via SSH and does not have access to a graphical session. -
Important
This guide assumes that you have completed setting up your KDE Wallet.
This details how to set our KDE Wallet to auto unlock upon login.
-
Ensure the chosen default KDE Wallet must be a wallet named
kdewallet
as described in the Setup section. -
Follow the subsequent steps depending on your wallet type:
Return to the following step once completed.
-
Restart the system.
Important
Wallet auto unlock will only work together with desktop autologin if the kdewallet
was configured with an empty password or passphrase. If you wish for the wallet to be secured with a password, desktop autologin must be disabled.
-
Depending on your choice of whether or not your wallet should be secured with a password, enable or disable autologin on your desktop.
-
Depending on your choice of desktop autologin setting, set the password for the
kdewallet
wallet:-
Launch the System Settings application.
-
Under the Security & Privacy group, expand the KDE Wallet section.
-
Click the Launch Wallet Manager button at the bottom right.
-
In the newly opened Wallet Manager window, navigate to the kdewallet wallet if you have multiple wallets.
-
Click the Change Password button on the top right.
-
Set the password to your user password if you have desktop autologin disabled.
-
Alternatively, set the password to an empty password if you have enabled desktop autologin.
-
Click the OK button.
-
-
If you are not using desktop autologin and have set the default wallet's password to your user password accordingly, install the
kwallet-pam
package.
- Set an empty passphrase to the GPG key tied to the
kdewallet
wallet.
This guide details on how we could solve the You're running in a KDE environment but the OS keyring is not available for encryption. Ensure you have kwallet running. error when launching Visual Studio Code.
-
Launch the Visual Studio Code application.
-
Press Ctrl + Shift + P simultaneously and type in
runtime
in the provided prompt. -
Click the Preferences: Configure Runtime Arguments option to open the
argv.json
file. -
Add the following key and value to the very end of the JSON dictionary:
{ ... ... ... "password-store": "gnome-libsecret", }
-
Restart the Visual Studio Code application and verify that the error is no longer present.