You are not logged in.

#1 2021-08-10 06:41:58

john-soda
Member
Registered: 2017-05-20
Posts: 14

[SOLVED] plasma ssh-add autoscript doesn't work w ssh-agent as service

I tried successfully to store my ssh-key passwords in kwallet with ksshaskpass like described in the arch wiki Using the KDE Wallet to store ssh key passphrases
I realized that I have to start the ssh-agent in plasma before. I did this like described in the arch wiki Start ssh-agent with systemd user.
But the weird thing is when on login my ssh-add.sh autostart script it's not possible to add my ssh keys to the ssh-agent. Instead I get the following stderr output

Could not open a connection to your authentication agent.

I checked that the autostart script really runs at login which is does.
I checked that the ssh-agent process is really running when the script runs with checking

ps -ef | grep "[s]sh-agent"

, which it does.
I checked that the script is running as me $USER.
I added a

sleep 2s

in the script before it runs

ssh-add

command to prevent a race condition.
But i really don't get why I get the stderr output

Could not open a connection to your authentication agent.

When I run the script manually after login it works like it should.

Hope somebody can help me out here.

Kind regards john-soda

Last edited by john-soda (2021-08-11 06:47:55)

Offline

#2 2021-08-10 07:43:48

john-soda
Member
Registered: 2017-05-20
Posts: 14

Re: [SOLVED] plasma ssh-add autoscript doesn't work w ssh-agent as service

It cam an idea to my mind. I think it has to do with this line which I export in my .zshrc file

export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"

When I source my .zshrc file in the autostart script, too. It works like it should.
Maybe I can only add the export line and not source the whole zshrc. Have to test this.

And I think I (or somebody never edited the arch wiki) have to update the documentation about this. in Start ssh-agent with systemd user

Last edited by john-soda (2021-08-10 07:46:12)

Offline

#3 2021-08-10 08:00:22

john-soda
Member
Registered: 2017-05-20
Posts: 14

Re: [SOLVED] plasma ssh-add autoscript doesn't work w ssh-agent as service

export this line in the autostart script works.

 export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"

I think it should be explicitly mentiond in the wiki when you run a start script for kde wallet you have to add this export line in the autostart script.
here Using the KDE Wallet to store ssh key passphrases
and here Start ssh-agent with systemd user.

Offline

#4 2021-08-10 09:07:36

nl6720
The Evil Wiki Admin
Registered: 2016-07-02
Posts: 595

Re: [SOLVED] plasma ssh-add autoscript doesn't work w ssh-agent as service

john-soda wrote:

I think it has to do with this line which I export in my .zshrc file

export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"

Correct. https://wiki.archlinux.org/title/SSH_ke … stemd_user says

export the environment variable SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket" in your login shell initialization file, such as ~/.bash_profile.

~/.zshrc is a configuration file for the interactive shell. Login managers such as SDDM don't source it, but they do source ~/.zprofile and ~/.zlogin.

You should instead place the export command in a configuration file for the login shell, i.e. ~/.zprofile.

Offline

#5 2021-08-11 06:44:52

john-soda
Member
Registered: 2017-05-20
Posts: 14

Re: [SOLVED] plasma ssh-add autoscript doesn't work w ssh-agent as service

Thanks so much for this valuable information, I did not know that!!!
I never heard or saw ~/.zprofile.
Maybe it would be helpful for other people like me, to make the wiki in this case a bit more dummy proof.

I mark this now as solved!

Offline

#6 2021-12-22 08:12:06

lorebett
Member
Registered: 2021-12-22
Posts: 15

Re: [SOLVED] plasma ssh-add autoscript doesn't work w ssh-agent as service

Sorry If I go back to this issue,

I seem to understand that there's an AUR package, plasma-workspace-agent-ssh, which automatically starts the ssh-agent and sets SSH_AUTH_SOCK.
For example, after installing the AUR package and login into the Plasma session, I get

> echo $SSH_AUTH_SOCK
/tmp/ssh-XXXXXXmqt4LI/agent.94605

Then, following the instructions found here https://wiki.archlinux.org/title/KDE_Wa … assphrases makes everything work.

For example

~/.config/autostart/ssh-add.desktop

[Desktop Entry]
Exec=ssh-add -q
Name=ssh-add
Type=Application

~/.config/plasma-workspace/env/askpass.sh (made executable)

#!/bin/sh

export SSH_ASKPASS='/usr/bin/ksshaskpass'

With these two files, upon logging into the Plasma session, Kwallet asks for the password for the ssh key.

Offline

Board footer

Powered by FluxBB