You are here

Getting passwords from KWallet on the cli

After a few years of using a Mac professionally I switched back to using Linux again. I'm using KDE because I'm most comfortable with that.

If you use KDE, you automatically use KWallet to store stuff like your wifi-password so you don't have to remember that yourself. It's encrypted but will be unlocked when you login. I wanted to use that to automount some cifs shares so I don't have to put my password in a plain textfile.

So how to do it? Simple. First use KWalletManager to create a folder, and create an item under 'passwords' inside this folder. Put your password there. I created a folder called 'HighKing' with an item 'cifs'.

Now you can simply read the contents of that item with kwallet-query, like this:

kwallet-query -f HighKing -r cifs kdewallet

Now, I can mount my share like this:

sudo /usr/sbin/mount.cifs //server/share /mnt/share -o domain=mydomain,username=myuser,password=`kwallet-query -f HighKing -r cifs kdewallet`

Works like a charm! :-)