git 无法读取“https://github.com”的用户名:没有这样的设备或地址

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18649403/
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 09:01:05  来源:igfitidea点击:

could not read Username for 'https://github.com': No such device or address

gitgithubdocker

提问by Rose Perrone

I'm using gitto build a dockerimage with this command: sudo docker build github.com/roseperrone/myproject, but I get this error:

我正在使用以下命令git构建docker图像:sudo docker build github.com/roseperrone/myproject,但出现此错误:

could not read Username for 'https://github.com': No such device or address

could not read Username for 'https://github.com': No such device or address

How should I provide my git credentials?

我应该如何提供我的 git 凭据?

I'm running inside an AWS ec2 instance.

我在 AWS ec2 实例中运行。

回答by Rose Perrone

Looking at the code, it doesn't look like there's an option to provide credentials, so instead I copied my id_rsakey, ran git clone, cdd into it, and ran docker build .

查看代码,似乎没有提供凭据的选项,因此我将我的id_rsa密钥、 run git clonecdd复制到其中,然后运行docker build .

回答by Wadu

I have the same issue and I recently joined github but this bug is annoying me so much. I have sucessfully fixed it,

我有同样的问题,我最近加入了 github,但这个错误让我非常恼火。我已经成功修复它,

First of all Generate an SSH keyand authenticate it.

首先生成一个SSH密钥并对其进行身份验证。

Remove any previous remote address if it doesn't work, now go to your repositiory and copy the ssh clone url.

如果它不起作用,请删除任何以前的远程地址,现在转到您的存储库并复制 ssh 克隆 URL。

now open type the following command :

现在打开键入以下命令:

git remote add origin [email protected]:username/your-repo.git

git remote add origin [email protected]:username/your-repo.git

replace usernameand your-repowith your username and repo.
now try to push your changes, run the following command.

usernameyour-repo替换为您的用户名和 repo。
现在尝试推送您的更改,运行以下命令。

git push origin master

git push origin master

I hope it will work for you.

我希望它对你有用。

回答by hallvors - restore Monica

To understand this error, it helps to recall that there are two ways to check out code from Github: with user name/password, and authenticating with an SSH key.

要理解这个错误,有必要回想一下从 Github 检出代码的两种方法:使用用户名/密码,以及使用 SSH 密钥进行身份验证。

In the Github UI, the "Clone or download" button offers two options: Clone with SSHand Use HTTPS. (You might only get both options if you have added SSH keys to your Github account, I don't know). Checking out code using the https-URL requires typing your user name and password to authenticate. The SSH option creates a git@github - URL and checking out does not ask for user name and password.

在 Github UI 中,“克隆或下载”按钮提供了两个选项:使用 SSH 克隆使用 HTTPS。(如果您已将 SSH 密钥添加到您的 Github 帐户,您可能只会获得这两个选项,我不知道)。使用 https-URL 检出代码需要输入您的用户名和密码以进行身份​​验证。SSH 选项会创建一个 git@github - URL 并且检出不需要用户名和密码。

I would recommend that you do notsave your Github account password on the EC2 machine or in the Docker configuration. Neither would I recommend that you copy your personal id_rsa file onto the EC2 instance. Instead, create a dedicated SSH keyfor this purpose on Github. Give it a suitable label and decide if you want to allow pushing code or just pulling. This means you can easily revoke access later should the key get lost or if you stop using this setup.

我建议你EC2的机器上或者在泊坞窗配置保存您的Github上的帐户密码。我也不建议您将个人 id_rsa 文件复制到 EC2 实例上。相反,请在 Github 上为此目的创建一个专用的 SSH 密钥。给它一个合适的标签,然后决定是允许推送代码还是只允许拉取。这意味着,如果密钥丢失或停止使用此设置,您可以在以后轻松撤销访问权限。

More info about how to use the generated SSH key in the Docker setup can be found in this question: Using SSH keys inside docker container

有关如何在 Docker 设置中使用生成的 SSH 密钥的更多信息可以在此问题中找到: 在 docker 容器内使用 SSH 密钥

Hope this helps :)

希望这可以帮助 :)

回答by wi1

In case anyone else comes across this question and needs help, in your Dockerfile clone your repo with your credentials by issuing the following command:

如果其他人遇到此问题并需要帮助,请在您的 Dockerfile 中通过发出以下命令使用您的凭据克隆您的存储库:

git clone https://{username}:{password}@github.com/{username}/project.git

Make sure your password is encoded http://meyerweb.com/eric/tools/dencoder/

确保您的密码已编码http://meyerweb.com/eric/tools/dencoder/

回答by Ekundayo Blessing Funminiyi

You need to update your Credential Manager hereas discussed in this issue

您需要在此处更新您的凭据管理器本期所述

回答by thompsor

I think you need to set the git config via the command line.

我认为您需要通过命令行设置 git config。

See the github setup documentation: https://help.github.com/articles/set-up-git#platform-all

参见 github 设置文档:https: //help.github.com/articles/set-up-git#platform-all

$ git config --global user.name "Your Name Here"
$ git config --global user.email "[email protected]"

Etc.

等等。