SSH Agent for WSL, Ubuntu 17.10

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
    
  2. 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
    ssh-add -D
    

Tips

Add multiple SSH keys in one command by commands like:

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

Notes

reference

Leave a Comment