Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

github

docker

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

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

How should I provide my git credentials?

I'm running inside an AWS ec2 instance.

like image 715
Rose Perrone Avatar asked Sep 06 '13 03:09

Rose Perrone


3 Answers

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.

In the Github UI, the "Clone or download" button offers two options: Clone with SSH and 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.

I would recommend that you do not save 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 key for 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.

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

Hope this helps :)

like image 139
hallvors Avatar answered Oct 10 '22 10:10

hallvors


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

First of all Generate an SSH key and authenticate it.

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

now open type the following command :

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

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

git push origin master

I hope it will work for you.

like image 32
Wadu Avatar answered Oct 10 '22 09:10

Wadu


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

like image 39
Rose Perrone Avatar answered Oct 10 '22 09:10

Rose Perrone