m81
m81

Reputation: 2317

git push error: could not read Username for 'https://github.com': Permission denied

I'm on CentOS 7 and trying to push to github. First I was using ssh, but my system seems to have some weird bug where my ssh keys keep disappearing (I know that's unbelievable, but I have no other explanation.) Instead, I've been trying to use https, but I'm unable to push to github and don't know why. Here's what happens:

$ git push origin remote
fatal: could not read Username for 'https://github.com': Permission denied

Can you help?

Upvotes: 0

Views: 1210

Answers (3)

m81
m81

Reputation: 2317

The problem was definitely that the version of git I was using had a bug.

Separately, I and my group partners are much more familiar with Linux now, and we recognize that using the same .ssh folder (as root, no less!) for all of our keys was a bad idea.

In any case, we eventually stopped mucking around with the server (since we really didn't know what we were doing) and deployed our website with Heroku instead. But thanks for all the help!

Upvotes: 0

Marcus Müller
Marcus Müller

Reputation: 36462

I've tried, and the only way I could produce something similar was by disowning parts of my .git files. Given the fact that SSH credentials, as you say, 'disappear', I'd guess this is actually what the error message says:

fatal: could not read Password 

i.e., you don't have read access to the file you're trying to read.

Now, the hunt is on for files in your home directory that are not readable by you:

cd
find -not -readable -print0 | xargs -0 ls -lh

Will give you details about all files that your user can't read that are in your home directory. Typically, you should only see a few lock files there. I suspect you have something in a .ssh folder, too, or in your git repositories.

Upvotes: 1

VonC
VonC

Reputation: 1328252

If you want to use https, you need the full url of your repo:

git remote set-url https://<yourLogin>@github.com/<yourLogin>/<yourRepo>

Then you can try a git push.
That will ask you for your GitHub account password, unless you have activated the 2FA (See "About Two-Factor Authentication"), in which case you would need to generate first a PAT (Personnal Acces Token).

Upvotes: 1

Related Questions