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

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

$
0
0
Worth mentioning the package 'keychain', which manages ssh-agent and eliminates 99.99% of all the garp in jojpi's reply.

Code:

sudo apt install keychain
In my .bashrc I have:

Code:

alias keystart='keychain -q --nogui --ignore-missing --agents ssh privkey1 privkey2 ; source ~/.keychain/$(hostname)-sh'alias keystop='keychain -q --stop all'
privkey1 and privkey2 are private keys in my ~/.ssh directory. You can add more keys to the list if desired.

Each time I login, I simply type

Code:

keystart
and I'm good to go. Obviously, you could wire up keystart to run in your .bashrc, I prefer to do it manually, and I don't have to do it very often.

When using keychain I only need to type the passphrase for my SSH key once per boot, unless I did a 'keystop'.

Code:

bls@pw~> keystartEnter passphrase for /home/bls/.ssh/idbls: bls@pw~> ssh-agentSSH_AUTH_SOCK=/tmp/ssh-l9avfCbXmDSz/agent.533697; export SSH_AUTH_SOCK;SSH_AGENT_PID=533698; export SSH_AGENT_PID;echo Agent pid 533698;bls@pw~> keystopbls@pw~> keystartEnter passphrase for /home/bls/.ssh/idbls: bls@pw~> 

Statistics: Posted by bls — Wed Feb 11, 2026 12:21 am



Viewing all articles
Browse latest Browse all 7995

Trending Articles