Git always ask passphrase for key

前端 未结 2 497
半阙折子戏
半阙折子戏 2021-01-30 02:25

I had a problem when using git at times.

When I use the command git pull origin my_branch or git fetch or git push origin my

2条回答
  •  梦毁少年i
    2021-01-30 03:22

    Like Nasreddine says, it's because your key is encrypted with a passphrase to prevent others from reading it.

    The most convenient way of using passphrased keys is by using ssh-agent to start an authentication agent (which runs in the background):

    $ eval "$(ssh-agent)"
    Agent pid 44304
    

    ...and then using ssh-add to register your key with the agent so that it's used automatically for subsequent SSH connections:

    $ ssh-add ~/.ssh/id_rsa
    Enter passphrase for /home/khanhpn/.ssh/id_rsa:
    

    You'll be asked to enter your passphrase when you run ssh-add, but you won't need to do so again while ssh-agent is running.

    You can find more information on GitHub. Also note that you'll have to do this every time you log in, so you might like to add the eval "$(ssh-agent)" step to your .profile script.

提交回复
热议问题