This article guides you how to set up keychain/keyring to avoid typing your password repeatedly, when using git.
To store passwords in the KDE wallet, you need to install
sudo pacman -S ksshaskpass
Then configure git to use it:
git config --global core.askpass /usr/bin/ksshaskpass
Alternatively you can use
GIT_ASKPASS environmental variable (in
.xinitrc for i3):
If you use KDE, you may set the environmental variable by making a script
~/.config/plasma-workspace/env/askpass.sh, as suggested by Arch Wiki.
You can temporarily store passwords in memory by using credential helper:
$ git config credential.helper 'cache'
By default credentials are stored for 15 minutes, to change number of seconds to cache credentials use timeout parameter (30 minutes in this example):
$ git config credential.helper 'cache --timeout=1800'
To clear credentials cache before time out execute command:
$ git credential-cache exit
You may check manual pages for more information:
$ man git-credential-cache
The methods aforementioned, configuring
.gitconfig, does not work for ssh connections (to github/gitlab). To avoid repeating passphrase, we have to set up
i3 is not like desktop environments, like KDE/Gnome, which provide a complete set of tools. Thus, we have first install a keyring/keychain tool to store passwords. Here we use
kwallet from KDE as an example.
ksshaskpass packages: (you may also install
kwalletmanager as a GUI manager for passwords)
sudo pacman -S kwallet ksshaskpass
Then, we need to configure
ssh-agent to connect to
kwallet to retrieve passphrases:
ssh-agentwhen X starts, add it in
eval $(ssh-agent -s)
We then need to add the RSA keys to
kwalletfor passphrases. Create a script called
ssh-add.sh, for example, containing the following:
ssh-add < /dev/null
i3starts by configuring
~/.config/i3/config(you may have to change the path of the script):
exec --no-startup-id $HOME/bin/i3cmds/ssh-add.sh
In KDE, the configuration will be way easier, since the packages have been installed and almost configured correctly.
Add the script
Remember to make it executable by
chmod +x ssh-add.sh.
As suggested by Arch Wiki, you may set the environmental variable
SSH_ASKPASS separately via a script
This should be enough. However, some distributions, like Kubuntu, do not start
ssh-agent automatically. You may have to start it by adding
eval $(ssh-agent -s).