解决github每次提交都要输入用户名和密码问题 SSH

这是github的安全设置,当你直接用https的方式向github push时,会要求输入用户名和密码。

解决方式是:git clone时改用SSH的方式。

1、在本地创建ssh密钥。

参考:https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

打开Git Bash,输入:

$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
> Generating public/private rsa key pair.
> Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter]
> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]

2、将创建的密钥复制添加到github的settings的ssh设置里。

参考:https://help.github.com/en/articles/adding-a-new-ssh-key-to-your-github-account

解决github每次提交都要输入用户名和密码问题 SSH_第1张图片

解决github每次提交都要输入用户名和密码问题 SSH_第2张图片

点击按钮

解决github每次提交都要输入用户名和密码问题 SSH_第3张图片

注:1、本地的ssh公钥一般在C:/user/用户名/.ssh/xxxxrsa.pub里,另外一个同名但是没有后缀名的文件里保存的是私钥;

2、也可以通过git gui的help->ssh查看SSH Key:

解决github每次提交都要输入用户名和密码问题 SSH_第4张图片

3、git clone 选择SSH地址,而不是HTTPS地址:

git clone [email protected]:your_repository_address.git

4、有时候git clone时会出现如下问题:

原文网址:https://help.github.com/en/articles/error-agent-admitted-failure-to-sign

Error: Agent admitted failure to sign

In rare circumstances, connecting to GitHub via SSH on Linux produces the error "Agent admitted failure to sign using the key". Follow these steps to resolve the problem.

When trying to SSH into GitHub on a Linux computer, you may see the following message in your terminal:

$ ssh -vT [email protected]
> ...
> Agent admitted failure to sign using the key.
> debug1: No more authentication methods to try.
> Permission denied (publickey).

For more details, see this issue report.

解决方式是:

# start the ssh-agent in the background
$ eval "$(ssh-agent -s)"
> Agent pid 59566
$ ssh-add
> Enter passphrase for /home/you/.ssh/id_rsa: [tippy tap]
> Identity added: /home/you/.ssh/id_rsa (/home/you/.ssh/id_rsa)

 

 

你可能感兴趣的:(解决github每次提交都要输入用户名和密码问题 SSH)