Git 推送不起作用错误“您必须使用个人访问令牌或 SSH 密钥”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51634406/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 13:09:59  来源:igfitidea点击:

Git push is not working Error "You must use a personal access token or SSH key"

gitgithubpushgithub-pages

提问by Sijith

Git is throwing error

Git抛出错误

"C:\Program Files (x86)\Git\bin\git.exe" push -u --recurse-submodules=check - 
-progress "origin" refs/heads/dev_civaplugin:refs/heads/dev_civaplugin
remote: Password authentication is not available for Git operations.
remote: You must use a personal access token or SSH key.
remote: See https://github.build.ge.com/settings/tokens or 
https://github.build.ge.com/settings/ssh
fatal: unable to access 
'https://github.build.ge.com/108012572/NextGenUT.git/': The requested URL 
returned error: 403
Done

 Press Enter or Esc to close console...

I cloned remote repository successfully using git extention and able to create new branch also but when tried to push my changes its throwing above error.

我使用 git extension 成功克隆了远程存储库,并且也能够创建新分支,但是当尝试推送我的更改时,它会抛出上述错误。

I created public and private key using Tools> putty> generate or import key my pc don't have > .SSH folder in user In git hub I created Personal access token also using Settings > Developer settings > Personal access tokens Not getting clear idea of what the issue is, any input is a great help

我使用工具> putty> 生成或导入密钥创建了公钥和私钥我的电脑没有> 用户中的.SSH 文件夹在git hub 我创建了个人访问令牌也使用设置> 开发人员设置> 个人访问令牌问题是什么,任何输入都是一个很大的帮助

回答by phd

See your git remote show origin— you have URL for the remote originas https://github.build.ge.com/108012572/NextGenUT.git/. HTTP(S) protocol certainly doesn't use SSH keys, for SSH keys you have to change the URL to use ssh://protocol. Or you have to pass your Github name in the HTTP(S) URL. So either

见你git remote show origin-你的网址为远程originhttps://github.build.ge.com/108012572/NextGenUT.git/。HTTP(S) 协议当然不使用 SSH 密钥,对于 SSH 密钥,您必须更改 URL 才能使用ssh://协议。或者您必须在 HTTP(S) URL 中传递您的 Github 名称。所以要么

git remote set-url origin https://[email protected]/108012572/NextGenUT.git

to use Github token or

使用 Github 令牌或

git remote set-url origin ssh://[email protected]/108012572/NextGenUT.git

to use SSH keys.

使用 SSH 密钥。

回答by Prashanth Sams

Go to step #6 directly [follow from step #1 if you have single sign-on]

直接转到第 6 步 [如果您使用单点登录,请从第 1 步开始操作]

  1. Generate an SSH key in your local machine (enter passphrase while creating key)
  1. 在本地机器上生成一个 SSH 密钥(在创建密钥时输入密码)
ssh-keygen -t rsa
  1. Copy the private key which starts with ssh-rsa
  2. Go to Github > settings > SSH and GPG keys
  3. Click on New SSH keyand paste the private that you've copied earlier, and create it
  1. 复制以开头的私钥 ssh-rsa
  2. 转到Github > 设置 > SSH 和 GPG 密钥
  3. 单击New SSH key并粘贴您之前复制的私有文件,然后创建它

enter image description here

在此处输入图片说明

  1. Now, enable SSO and authorize your org
  1. 现在,启用 SSO 并授权您的组织

enter image description here

在此处输入图片说明

  1. Make sure that the newly created ssh private key is added into the SSH authentication agent
  1. 确保将新创建的 ssh 私钥添加到 SSH 身份验证代理中
ssh-add <your-private-key>
(e.g., ssh-add id_rsa)

Note:By default, it will have your id_rsaprimary key only; so, you need to add your custom private key in it.

注意:默认情况下,它只有你的id_rsa主键;因此,您需要在其中添加自定义私钥。