本地配置多个ssh密钥小记

         之前在https://github.com中的项目发现提交代码的时候提示:

MacBook-Pro:pattern j1$ git push
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: unable to access 'https://github.com/wenjing-bonnie/pattern.git/': The requested URL returned error: 403

         这个是由于github将之前的密码凭证从2021年8月13日已经不在使用,必须使用个人访问令牌代替密码。网上有一些怎么生成token的方式,但我在配置的时候没有搞清楚什么有效期,所以还是使用了ssh密钥的方式,因为之前已经在github上配置了密钥,所以直接将该项目下的.git目录下的config文件中的url换成url = git@github.com:wenjing-bonnie/pattern.git,这样在执行gitpush命令之后,但是在提交的时候又提示下面的内容:

MacBook-Pro:pattern j1$ git push -u origin master
Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

        这个跟我在本地有好几个ssh密钥的原因,所以需要配置下对于 github提交的时候对应的密钥文件,下面是配置密钥文件的过程:

  • 1.进入到.ssh文件夹
  • 2.通过touch config创建config文件
  • 3.在config文件中添加如下:
#github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_wenjing

        在执行git push命令的时候,已经可以将代码提交到github

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值