From my understanding, x11 shares stuff among terminals, so at boot I can run the ssh-agent.
However, now I have migrated to wayland (sway) and I am having trouble getting the same behaviour from the ssh-agent.
The expected behaviour:
After booting manjaro, I can run
ssh-add and it will prompt me for the passphrase. After entering it, I should be able to use this ssh-key until I restart the machine. Also I should be able to use it in newly spawned terminals. The agent should be shared.
What I have tried so far:
I have tried all kinds of different snippets in my .zshrc. (I was using bash on i3 before, so maybe I am misunderstanding something here itself):
From my understanding, this line is supposed to run the ssh-agent:
eval `ssh-agent -s`
When I have this line, and I use
ssh-add, I receive the prompt and the password will be stored but it won’t be shared with other terminals.
When checking the arch wiki I came across this snippet:
if ! pgrep -u "$USER" ssh-agent > /dev/null; then ssh-agent -t 1h > "$XDG_RUNTIME_DIR/ssh-agent.env" fi if [[ ! -f "$SSH_AUTH_SOCK" ]]; then source "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null fi
While browsing the web, I have come across similar snippets like these:
if ! pgrep -u "$USER" ssh-agent > /dev/null; then ssh-agent -t 1h > "$XDG_RUNTIME_DIR/ssh-agent.env" fi
or this one:
if [ -z "$SSH_AUTH_SOCK" ] ; then eval `ssh-agent -s` ssh-add ~/.ssh/id_rsa fi
But none seem to work for me.
Also when I use
echo $SSH_AUTH_SOCK I noticed that the output is different in each terminal that I have opened. Shouldn’t this point to the same sock?
Has anyone managed to produce the behaviour I described? Because I used to have it like that when using i3.