尝试删除旧的SSH密钥,但是找不到它?

时间:2018-08-03 07:09:17

标签: git github ssh

我正面临着类似的problem,我无法将代码推送到仓库中。因此,尝试访问~/.ssh但未找到它吗?

我还确保在全局级别上同时配置了用户和电子邮件,如下所示:

git config --global user.name "New Name"
git config --global user.email "New Email"

但是当我尝试推送我的代码时,它仍然遇到拒绝权限的问题?这个隐藏的ssh密钥在哪里?

以下是我得到的例外情况

  

远程:对newUser / testing.git的权限已拒绝oldUserName。   严重:无法访问“ https://github.com/newUser/testing.git/”:请求的URL返回错误:403

更新

当我运行命令git remote -v时:

origin  https://github.com/newUser/testing.git (fetch)
origin  https://github.com/newUser/testing.git (push)

2 个答案:

答案 0 :(得分:0)

您看到此错误,是因为您试图将所做的更改推送到您无权访问的存储库中。签出-

的输出
git remote -v

这应该向您显示指向远程github帐户的来源。如果您的网址不正确,则可以通过-

设置正确的位置
git remote set-url origin <urltoyourremote>

希望这会有所帮助。

答案 1 :(得分:0)

您正在通过 https 使用 git ,与SSH无关。

以下是通过SSH访问您的存储库的步骤:

  1. 将您的仓库从HTTPS切换到SSH:

    git remote remove origin
    git remote add origin git@github.com:newUser/testing.git
    
  2. 生成新的SSH密钥(除非您拥有一个):

    ssh-keygen -t rsa -b 4096 -C "newUser@example.com"
    

    更详细的信息是here

  3. 向您的Github帐户添加新的SSH密钥:

    关注these steps

  4. ~/.ssh/config中添加以下内容:

    Host github.com
      User git
      IdentityFile ~/.ssh/id_rsa
    
  5. 享受