SSH Agent for WSL and Ubuntu

Related:


SSH Agent remembers SSH Public Key authentication for a period of time.

  1. add to ~/.bashrc:

    if [ -z "$(pgrep ssh-agent)" ]; then
       rm -rf /tmp/ssh-*
       eval $(ssh-agent -s) > /dev/null
    else
       export SSH_AGENT_PID=$(pgrep ssh-agent)
       export SSH_AUTH_SOCK=$(find /tmp/ssh-* -name agent.*)
    fi
    1. open a new Terminal:
    ssh-add -t 30m ~/.ssh/mygithubkey

-t 30m : remember authentication for a period of time (here, 30 minutes) 3. When SSHing, you can optionally remote all SSH keys from RAM by

```sh
ssh-add -D
```

Tips

Add multiple SSH keys in one command by commands like:

ssh-add ~/.ssh/{mygithub,mybitbucket}

Notes

reference