extrawurst / gitui

Blazing πŸ’₯ fast terminal-ui for git written in rust πŸ¦€
MIT License
18.58k stars 573 forks source link

Bad credentials are displayed in macOS #1185

Closed Coordinate-Cat closed 1 year ago

Coordinate-Cat commented 2 years ago

Describe the bug When I push, I get "Error push falied:git error:Bad credentials." and cannot push properly. Sorry, I saw a similar issue standing in the past, but could not resolve it... https://github.com/extrawurst/gitui/issues/495 https://github.com/extrawurst/gitui/issues/615 https://github.com/extrawurst/gitui/issues?q=bad+credentials

To Reproduce After pressing p on gitui, you will be asked for your password, and a modal will appear after you enter it.

Expected behavior I should be able to set up ssh, but I want to be able to push and pull.

Screenshots

γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2022-04-03 11 18 10

Context (please complete the following information):

Additional context

extrawurst commented 2 years ago

duplicate of #495 ?

Coordinate-Cat commented 2 years ago

@extrawurst After a lot of trial and error, I found the following solution. But every time it asks for an account name and password (PAT)...

γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2022-04-08 12 22 22
  1. add config
    
    cd ~/.ssh
    touch config
    vi config

Host github.com UpdateHostKeys yes

2. ssh-keygen command
ssh with ECDSA(https://github.blog/2021-09-01-improving-git-protocol-security-github/)

cd ~/.ssh ssh-keygen -t ecdsa -b 521 -C "your_email@example.com" ssh-add id_ecdsa

copy

pbcopy < ~/.ssh/id_ecdsa.pub


3. Github > Settings > New SSH key
4. make PAT(https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories#changing-a-remote-repositorys-url)
5. gitui
  5-1. push
  5-2. You will be prompted for an account name. (I get asked every time.)
     `Coordinate-Cat`
  5-3. You will be asked to enter password. (I get asked every time.)
     Enter the PAT you did in step 4 (not the github password)
extrawurst commented 2 years ago

@Coordinate-Cat switching from ssh to https based remotes does not exactly fix the problem, does it?

etnt commented 2 years ago

fyi: I had the same problem on my Mac. But by adding the UpdateHostKeys, as suggested + using ssh-add, the problem went away. (excellent tool btw :-) )

Coordinate-Cat commented 2 years ago

@extrawurst @etnt Thanks for your valuable input! I was in a long slumber.

I'm still not sure what caused it, but it's all sorted out. For the benefit of lost lambs like me, I share the following process that solved the problem.

make config file

mkdir ~/.ssh 
cd ~/.ssh
touch config
vim config

write config

Host github github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/github

make ssh-key

ssh-keygen -t ecdsa -C "example@gmail.com"
Type `github` in the first question
pbcopy < ~/.ssh/github.pub
ssh-add ~/.ssh/github
ssh -T git@github.com

This tool is seriously comfortable! It is safe to close this issue.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had any activity half a year. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.