Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 5
    FYI, the reason it checks for $? -ge 2 is because exit code 1 is when the ssh-agent has no keys, but ssh-agent is already running. Commented Aug 9, 2019 at 23:00
  • Note that some desktop environments (e.g. Ubuntu Mate) may automatically run ssh-agent for you but you have to run ssh-add without parameters to add private keys into your keyring. For example, when you first connect to remote machine that contains private keys, you have to run ssh-add on the remote matchine to get the keys into your client machine keyring. Commented Mar 21, 2020 at 9:51
  • 1
    I am curious, when it's possible to set this up in a few lines of a shell script, what is the purpose of keychain, ssh-ident or other projects. Commented Apr 12, 2020 at 10:29
  • 1
    FYI, if you have a .bashrc file, you have to put theses lines instead of .profile (see head ~/.profile for explanations) Commented Nov 10, 2020 at 10:01
  • 3
    @Asenar No. .profile is the right file for what runs at login time. .bashrc runs every time you open a terminal. See superuser.com/questions/183870/… Commented Nov 10, 2020 at 10:50