解决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 "your_email@example.com"
> 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

点击"+"下的Settings

选择"SSH and GPG keys"

点击按钮"Add SSH key"

点击"New SSH key"

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

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

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

git clone git@github.com: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 git@github.com
> ...
> 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)

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值