When I'm running Gnome, ssh-agent will run ssh-add upon slogin/ssh if the identity is not loaded. I want to mimic this behavior on remote shells, but everything I find suggests to run ssh-add upon login. I only want to run ssh-add if I subsequently run slogin/ssh on the remote shell, not every time I login.
Ubuntu – Doing an ssh-add upon ssh/slogin if key is not in ssh-agent
ssh-agent
Related Question
- Ubuntu – How to get OpenSSH to use ksshaskpass under KDE
- Ubuntu – ssh-agent is not used when ssh is launched from panel launcher (via `gnome-terminal –command`)
- Ubuntu – How to avoid typing ssh-add everytime
- Ubuntu – Why can’t I interact with the ssh-agent? (e.g. ssh-add -D doesn’t work)
- Ubuntu – Use gnome-keyring as ssh agent instead of openssh
Best Answer
I worked out a solution for this via the bash shell.
Add to .bashrc: