Remember git passphrase in WSL

后端 未结 3 661
無奈伤痛
無奈伤痛 2021-01-11 14:52

I run Windows 10 with WSL. I have the desired behaviour on one computer, but cannot replicate elsewhere. Here\'s what I\'m after:

  1. First time I run a remote g
3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-11 15:13

    I tried the option to add AddKeysToAgent yes to ~/.ssh/config but it doesn't keep it between new tabs on the terminal.

    The best solution I found so far is to do the following:

    sudo apt install keychain
    

    Find your hostname using the terminal:

    hostname
    

    Then add the following to your ~/.bashrc or ~/.zshrc file:

    /usr/bin/keychain --nogui ~/.ssh/id_rsa
    source $HOME/.keychain/YOUR-HOSTNAME-HERE-sh
    

    Now, each time you reboot, you’ll have to enter your passphrase. But you only have to do it one time until you reboot or terminate WSL.

    If you want to use the same key you already have on Windows you can follow this post Sharing SSH keys between Windows and WSL 2

提交回复
热议问题