This always takes me a while to figure out when installing a new system so here is a foolproof guide to do this right once and for all. Kudos to all the people in this Manjaro thread. However, this should work on any system with KDE and systemd.
Make sure to install required packages:
sudo pacman -Syu --needed kwallet5 ksshaskpass kwalletmanager kwallet-pam signon-kwallet-extensionCreate a new shell script named ssh-askpass.sh in /etc/profile.d/:
#!/bin/sh
# in /etc/profile.d/ssh-askpass.sh
export SSH_ASKPASS=/usr/bin/ksshaskpass
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR"/ssh-agent.socketIt needs to be at this location, adding this to user directories in $HOME did not seem to have the desired effect. But perhaps adding to $HOME/.profile could solve this and root privelages might not be needed for this step.
Create an ssh-agent systemd service for your local user:
mkdir -p ~/.config/systemd/user
touch ~/.config/systemd/user/ssh-agent.serviceContents of ~/.config/systemd/user/ssh-agent.service:
[Unit]
Description=SSH agent (ssh-agent)
[Service]
Type=simple
Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
Environment=DISPLAY=:0
ExecStart=ssh-agent -D -a $SSH_AUTH_SOCK
ExecStop=kill -15 $MAINPID
[Install]
WantedBy=default.target
Then we just need to enable the service and start the service:
systemctl --user daemon-reload
systemctl --user enable ssh-agent.service
systemctl --user start ssh-agent.service # just to check it is workingCreate a desktop entry to automatically add your keys:
touch ~/.config/autostart/ssh-add.desktopwith contents:
[Desktop Entry]
Exec=ssh-add -q ~/.ssh/key1 ~/.ssh/key2 ~/.ssh/key3 < /dev/null
Name=ssh-add
Type=Application
Reboot and you should be prompted for your passwords at the next login:
sudo systemctl rebootIf there is no prompt after login, keys can also be stored in the wallet manually:
ssh-add -q /path/to/key < /dev/null