Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8037

Networking and servers • Re: ssh-agent looses its keys at session opening

$
0
0
Then I close the SSH connection between the PC and the PI3, I open a new one, ssh-add -l again, but the PI3 ssh agent does not answer. So I enter "eval $(ssh-agent)" to wake it up, and then ssh-add -l again. And I see that the agent has no key, I have to add it again.
eval $(ssh-agent) does not wake up any previous agent. It starts a brand new agent and configures your current shell to use this new one. Hence it always starts with no keys loaded.

When you start an agent it prints some information that is crucial for connecting to it later:

Code:

pi@pj:~ $ ssh-agent SSH_AUTH_SOCK=/tmp/ssh-XMy2Z3qbfqVU/agent.98585; export SSH_AUTH_SOCK;SSH_AGENT_PID=98586; export SSH_AGENT_PID;echo Agent pid 98586;
The eval $() construct tells your shell to consume this information as commands, which allows subsequent programs in the same session to find the agent. It does not make it easy for other sessions to find the same agent.

You could write the settings to a file before consuming them, so that you can later consume them again in other sessions:

Code:

sess1$ ssh-agent > ~/.agentsess1$ . ~/.agentAgent pid 98586sess2$ . ~/.agentAgent pid 98586
You might be better to run an agent as part of your GUI session on Kubuntu (you probably are), and forward that agent to the Pi using ssh -A, so the Pi can use the same keys and agent.

Statistics: Posted by jojopi — Wed Feb 11, 2026 12:02 am



Viewing all articles
Browse latest Browse all 8037

Trending Articles