Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bad credentials despite normal cli being fine #495

Open
jamesb93 opened this issue Jan 17, 2021 · 83 comments
Open

bad credentials despite normal cli being fine #495

jamesb93 opened this issue Jan 17, 2021 · 83 comments
Labels
bug Something isn't working help wanted Extra attention is needed windows

Comments

@jamesb93
Copy link

Describe the bug
I can push from the command line normally git push, but pushing within gitui always fails due to 'bad credentials'.

To Reproduce
Commit some changes in gitui, press p to trigger a push. It always fails.

Expected behavior
Pushing should succeed as my ssh key is valid and works outside of gitui.

Screenshots
If applicable, add screenshots to help explain your problem.

Context (please complete the following information):

  • OS/Distro : macOS 11, arm m1
  • GitUI Version: 0.11.0
  • Rust version: 1.49 stable

Additional context
gitui installed from cargo.

@dmytro-tolkodubov
Copy link

The same.
Mac OS 10.15.4
GitUI version 0.11.0 (installed via brew)

@extrawurst
Copy link
Owner

Unfortunately I cannot reproduce the issue. Anything special about the way you push?

@dmytro-tolkodubov
Copy link

Thanks for a quick reply, Stephan!
Anything special about the way you push --> nope, just pressing p once commited and ready to push.

@dmytro-tolkodubov
Copy link

i think the issues is in the fact gitui does git push <branch_name> instead of git push origin <branch_name>. Is there any way to make the latter the default push option?

@extrawurst
Copy link
Owner

can you share the way your remote is setup in .git/config?
for it looks like:

[remote "origin"]
        url = [email protected]:extrawurst/gitui.git

@extrawurst
Copy link
Owner

i think the issues is in the fact gitui does git push <branch_name> instead of git push origin <branch_name>. Is there any way to make the latter the default push option?

since you use the brew-version it only supports pushing to origin right now

@dmytro-tolkodubov
Copy link

dmytro-tolkodubov commented Jan 19, 2021

My remote is setup in this way:

[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = [email protected]:**/pipeline-base.git
fetch = +refs/heads/
:refs/remotes/origin/

[branch "develop"]
remote = origin
merge = refs/heads/develop
[branch "release/1.12.0"]
remote = origin
merge = refs/heads/release/1.12.0
[branch "release/1.12.1"]
remote = origin
merge = refs/heads/release/1.12.1

And if i do git push <branch_name> from the cli, i get
**fatal: 'test' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.** --> which results in bed credentials in gitui i think.
But if i do git push origin <branch_name> all works fine. Might be something with my git setup, but so far was working like a charm.
Thanks

@extrawurst
Copy link
Owner

@dmytro-tolkodubov I cannot see anything obviously problematic unfortunately.
Could you run gitui -l so that it writes to the log file and share if there is anything more telling in there?

@dmytro-tolkodubov
Copy link

dmytro-tolkodubov commented Jan 19, 2021

@extrawurst did execute with -l flag, but can't find the file with with the log output :).

@extrawurst
Copy link
Owner

@extrawurst did execute with -l flag, but can't find the output where the log should have been saved to :).

https://github.com/extrawurst/gitui#diagnostics

@dmytro-tolkodubov
Copy link

dmytro-tolkodubov commented Jan 19, 2021

Ah, thanks! This is what i see there:

tail $HOME/Library/Caches/gitui/gitui.log
10:48:45 [TRACE] (1) gitui::app: [src/app.rs:278] update
10:48:45 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:93] request
10:48:45 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 14046281010676946994] (type: WorkingDir, untracked: true)
10:48:45 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 6842313692465843766] (type: Stage, untracked: true)
10:48:45 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 14046281010676946994 (type: WorkingDir, untracked: true)
10:48:45 [TRACE] (5) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 6842313692465843766 (type: Stage, untracked: true)
10:48:45 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Diff
10:48:45 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Status
10:48:45 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Status
10:48:46 [TRACE] (1) gitui::app: [src/app.rs:212] event: Input(Key(KeyEvent { code: Char('c'), modifiers: CONTROL }))

@extrawurst
Copy link
Owner

you did not try to push in that session

@dmytro-tolkodubov
Copy link

dmytro-tolkodubov commented Jan 19, 2021

i think i did, here is the error line (did not paste the whole log, it is a bit bigger)

10:48:35 [TRACE] (1) gitui::app: [src/app.rs:278] update
10:48:35 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:93] request
10:48:35 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 8133653752159640044] (type: WorkingDir, untracked: true)
10:48:35 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 16630248863231777639] (type: Stage, untracked: true)
10:48:35 [TRACE] (2) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 16630248863231777639 (type: Stage, untracked: true)
10:48:35 [TRACE] (5) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 8133653752159640044 (type: WorkingDir, untracked: true)
10:48:35 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Diff
10:48:35 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Status
10:48:35 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Status
10:48:39 [DEBUG] (7) asyncgit::sync::remotes: creds: '[email protected]:***/pipeline-base.git' Some("git") (SSH_KEY | SSH_MEMORY | SSH_CUSTOM)
10:48:40 [DEBUG] (7) asyncgit::sync::remotes: creds: '[email protected]:***/pipeline-base.git' Some("git") (SSH_KEY | SSH_MEMORY | SSH_CUSTOM)
10:48:40 [INFO] push progress: Some(PushProgress { state: Pushing, progress: 100 })
10:48:40 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Push
10:48:40 [ERROR] push error: git error:Bad credentials.

@extrawurst
Copy link
Owner

Ok I have no idea what's happening there.
Maybe @jamesb93 can check the config and log, too.

@dmytro-tolkodubov
Copy link

Thanks for the great tool though!

@extrawurst
Copy link
Owner

Thanks man, the push feature is still quiet new and there are so many flavours of how this can fail, but I am sure we will find the culprit of this.

Two things for you to keep in mind:
a) if you have credentials you don't want to share in a post here, the first post matters as every subscriber might receive the original version as an email.
b) use ``` to annotate code/logs whatever for better readability.

@dmytro-tolkodubov
Copy link

Thanks! There were no creds, but some info i thought i would not publish, not something confidential :)
b) use ``` to annotate code/logs whatever for better readability.
I used that each time, but did not like the formatting, the config lines spilt, etc - hence had to stick to pure formatting.

@austinbutler
Copy link

Same issue on macOS, but Linux works fine. Using 0.11.0 installed from nixpkgs.

My config:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[remote "origin"]
        url = [email protected]:austinbutler/home-manager.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

Log:

23:06:19 [TRACE] (1) gitui::app: [src/app.rs:212] event: Input(Key(KeyEvent { code: Char('p'), modifiers: NONE }))
23:06:19 [TRACE] (1) asyncgit::push: [asyncgit/src/push.rs:140] request
23:06:19 [INFO] push progress: None
23:06:19 [TRACE] (1) gitui::app: [src/app.rs:278] update
23:06:19 [INFO] push progress receiver spawned
23:06:19 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:93] request
23:06:19 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 12116648514797157301] (type: WorkingDir, untracked: true)
23:06:19 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 9610033249583839640] (type: Stage, untracked: true)
23:06:19 [TRACE] (4) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 9610033249583839640 (type: Stage, untracked: true)
23:06:19 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 12116648514797157301 (type: WorkingDir, untracked: true)
23:06:19 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Diff
23:06:19 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Status
23:06:19 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Status
23:06:19 [TRACE] (1) gitui::app: [src/app.rs:278] update
23:06:19 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:93] request
23:06:19 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 6258322933600415971] (type: WorkingDir, untracked: true)
23:06:19 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 15050898553161509101] (type: Stage, untracked: true)
23:06:19 [TRACE] (4) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 15050898553161509101 (type: Stage, untracked: true)
23:06:19 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 6258322933600415971 (type: WorkingDir, untracked: true)
23:06:19 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Diff
23:06:19 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Status
23:06:19 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Status
23:06:19 [DEBUG] (7) asyncgit::sync::remotes: creds: '[email protected]:austinbutler/home-manager.git' Some("git") (SSH_KEY | SSH_MEMORY | SSH_CUSTOM | SSH_INTERACTIVE)
23:06:19 [DEBUG] (7) asyncgit::sync::remotes: creds: '[email protected]:austinbutler/home-manager.git' Some("git") (SSH_KEY | SSH_MEMORY | SSH_CUSTOM | SSH_INTERACTIVE)
23:06:19 [INFO] push progress: Some(PushProgress { state: Pushing, progress: 100 })
23:06:19 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Push
23:06:20 [ERROR] push error: git error:Bad credentials.
23:06:20 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Push
23:06:20 [TRACE] (1) gitui::app: [src/app.rs:278] update
23:06:20 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:93] request
23:06:20 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 12063500518878365465] (type: WorkingDir, untracked: true)
23:06:20 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 1608129730030349621] (type: Stage, untracked: true)
23:06:20 [TRACE] (4) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 1608129730030349621 (type: Stage, untracked: true)
23:06:20 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 12063500518878365465 (type: WorkingDir, untracked: true)
23:06:20 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Diff
23:06:20 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Status
23:06:20 [TRACE] (1) gitui::app: [src/app.rs:295] update_git: Status
23:06:21 [TRACE] (1) gitui::app: [src/app.rs:212] event: Input(Key(KeyEvent { code: Esc, modifiers: NONE }))
❯ git push master
fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
❯ git push origin master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 294 bytes | 294.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
To gitlab.com:austinbutler/home-manager-work.git
   5e49466..5fcf4f2  master -> master

@ser-drephs
Copy link
Contributor

Hi, same Problem here on Windows 10 using Windows Terminal.

Can't provide a Log, because Log Folder is not documented for Windows.

image

[remote "origin"]
        url = https://[...]
        fetch = +refs/heads/*:refs/remotes/origin/*

@extrawurst
Copy link
Owner

@ser-drephs

Can't provide a Log, because Log Folder is not documented for Windows.

dirs-next docs say it is supposed to be here: {FOLDERID_LocalAppData}
keep in mind that you still need to run gitui -l to produce logging.

would be cool if you could validate this on windows and make PR for the readme to extend the documentation for where to find the win logs

@ser-drephs
Copy link
Contributor

@extrawurst created PR #579 for readme.

@ser-drephs
Copy link
Contributor

Log:

15:22:24 [ERROR] failed loading key binding: missing field `rename_branch`
15:22:24 [TRACE] (1) gitui::app: [src\app.rs:278] update
15:22:24 [TRACE] (1) asyncgit::status: [asyncgit\src\status.rs:95] request: [hash: 13786298131209757784] (type: WorkingDir, untracked: true)
15:22:24 [TRACE] (1) asyncgit::status: [asyncgit\src\status.rs:95] request: [hash: 60621207339198373] (type: Stage, untracked: true)
15:22:24 [TRACE] (1) gitui::app: [src\app.rs:212] event: Input(Resize(198, 40))
15:22:25 [TRACE] (3) asyncgit::status: [asyncgit\src\status.rs:152] status fetched: 60621207339198373 (type: Stage, untracked: true)
15:22:25 [TRACE] (1) gitui::app: [src\app.rs:295] update_git: Status
15:22:29 [TRACE] (1) gitui::app: [src\app.rs:212] event: Input(Key(KeyEvent { code: Char('p'), modifiers: NONE }))
15:22:29 [DEBUG] (1) git2::cred: executing credential helper "sh" "-c" "git credential-wincred get"
15:22:29 [DEBUG] (1) git2::cred: `sh` failed to spawn: Das System kann die angegebene Datei nicht finden. (os error 2)
15:22:29 [DEBUG] (1) git2::cred: executing credential helper "git" "credential-wincred" "get"
15:22:29 [TRACE] (1) git2::cred: [C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\git2-0.13.12\src\cred.rs:403] credential helper stderr ---

15:22:29 [TRACE] (1) git2::cred: [C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\git2-0.13.12\src\cred.rs:421] ignoring output line: 
15:22:29 [TRACE] (1) asyncgit::push: [asyncgit\src\push.rs:140] request
15:22:29 [INFO] push progress: None
15:22:29 [TRACE] (1) gitui::app: [src\app.rs:278] update
15:22:29 [INFO] push progress receiver spawned
15:22:29 [TRACE] (1) asyncgit::status: [asyncgit\src\status.rs:89] request blocked, still pending
15:22:29 [TRACE] (1) asyncgit::status: [asyncgit\src\status.rs:95] request: [hash: 10069514427976502005] (type: Stage, untracked: true)
15:22:29 [DEBUG] (7) asyncgit::sync::remotes: creds: 'https://[...]' None (USER_PASS_PLAINTEXT | DEFAULT)
15:22:29 [INFO] push progress: Some(PushProgress { state: Pushing, progress: 100 })
15:22:29 [TRACE] (1) gitui::app: [src\app.rs:295] update_git: Push
15:22:29 [TRACE] (1) gitui::app: [src\app.rs:278] update
15:22:29 [TRACE] (1) asyncgit::status: [asyncgit\src\status.rs:89] request blocked, still pending
15:22:29 [TRACE] (1) asyncgit::status: [asyncgit\src\status.rs:89] request blocked, still pending
15:22:29 [TRACE] (3) asyncgit::status: [asyncgit\src\status.rs:152] status fetched: 10069514427976502005 (type: Stage, untracked: true)
15:22:29 [TRACE] (1) gitui::app: [src\app.rs:295] update_git: Status
15:22:29 [ERROR] push error: git error:failed to set credentials: Falscher Parameter.
; class=Os (2)
15:22:29 [TRACE] (1) gitui::app: [src\app.rs:295] update_git: Push
15:22:29 [TRACE] (1) gitui::app: [src\app.rs:278] update
15:22:29 [TRACE] (1) asyncgit::status: [asyncgit\src\status.rs:89] request blocked, still pending
15:22:29 [TRACE] (1) asyncgit::status: [asyncgit\src\status.rs:95] request: [hash: 6192809872892578921] (type: Stage, untracked: true)
15:22:30 [TRACE] (3) asyncgit::status: [asyncgit\src\status.rs:152] status fetched: 6192809872892578921 (type: Stage, untracked: true)
15:22:30 [TRACE] (1) gitui::app: [src\app.rs:295] update_git: Status

@extrawurst extrawurst added bug Something isn't working help wanted Extra attention is needed windows labels Mar 10, 2021
@non-descriptive
Copy link

non-descriptive commented Mar 11, 2021

Platform: OSX 10.15.7
gitui: 0.12 at b5ef9b10f1e0e6e0c21a55d9083b4e40c1f759b8
rustc 1.50.0 (cb75ad5db 2021-02-10)

Same here. Our git repo lives behind VPN. If I try to pull/push without connecting to it from console it will yield error after some timeout.

ssh: connect to host gitlab.domain.com port 22: Operation timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

But when I am connected it fetch/push just fine from console, but gitui for some reason fails and displays two modal windows:

  1. fetch failed. git error: Bad credentials., there's Close [⏎] hint on the command panel. Works just fine
  2. pull : done - displayed when the first one closed, also shows Close [⏎] hint but do not react to it.
10:38:30 [TRACE] (6) mio::poll: [/Users/user/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.7.9/src/poll.rs:478] registering event source with poller: token=Token(0), interests=READABLE
10:38:30 [TRACE] (1) gitui::app: [src/app.rs:294] update
10:38:30 [TRACE] (6) mio::poll: [/Users/user/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.7.9/src/poll.rs:478] registering event source with poller: token=Token(1), interests=READABLE
10:38:30 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 10118950357809785858] (type: WorkingDir, untracked: true)
10:38:30 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 8626102265759462768] (type: Stage, untracked: true)
10:38:31 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 8626102265759462768 (type: Stage, untracked: true)
10:38:31 [TRACE] (1) gitui::app: [src/app.rs:312] update_git: Status
10:38:31 [TRACE] (2) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 10118950357809785858 (type: WorkingDir, untracked: true)
10:38:31 [TRACE] (1) gitui::app: [src/app.rs:312] update_git: Status
10:38:31 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:90] request
10:38:31 [TRACE] (1) gitui::app: [src/app.rs:312] update_git: Diff
10:38:31 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:90] request
10:38:32 [TRACE] (1) gitui::app: [src/app.rs:228] event: Input(Key(KeyEvent { code: Char('f'), modifiers: NONE }))
10:38:32 [TRACE] (1) asyncgit::fetch: [asyncgit/src/fetch.rs:70] request
10:38:32 [TRACE] (1) gitui::app: [src/app.rs:294] update
10:38:32 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:90] request
10:38:32 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 11179346055135384458] (type: WorkingDir, untracked: true)
10:38:32 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 3478892476685171275] (type: Stage, untracked: true)
10:38:32 [DEBUG] (7) asyncgit::sync::remotes::push: creds: '[email protected]:corp/platform.git' Some("git") (USER_PASS_PLAINTEXT | SSH_KEY | SSH_MEMORY | SSH_CUSTOM)
10:38:32 [TRACE] (1) gitui::app: [src/app.rs:312] update_git: Diff
10:38:32 [DEBUG] (7) asyncgit::sync::remotes::push: creds: '[email protected]:corp/platform.git' Some("git") (USER_PASS_PLAINTEXT | SSH_KEY | SSH_MEMORY | SSH_CUSTOM)
10:38:32 [TRACE] (1) gitui::app: [src/app.rs:312] update_git: Fetch
10:38:32 [ERROR] fetch error: git error:Bad credentials.
10:38:32 [TRACE] (1) gitui::app: [src/app.rs:294] update
10:38:32 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:90] request
10:38:32 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:89] request blocked, still pending
10:38:32 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:89] request blocked, still pending
10:38:32 [TRACE] (1) gitui::app: [src/app.rs:312] update_git: Fetch
10:38:32 [TRACE] (1) gitui::app: [src/app.rs:294] update
10:38:32 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:90] request
10:38:32 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:89] request blocked, still pending
10:38:32 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:89] request blocked, still pending
10:38:32 [TRACE] (4) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 3478892476685171275 (type: Stage, untracked: true)
10:38:32 [TRACE] (1) gitui::app: [src/app.rs:312] update_git: Status
10:38:32 [TRACE] (1) gitui::app: [src/app.rs:312] update_git: Diff
10:38:32 [TRACE] (1) gitui::app: [src/app.rs:312] update_git: Diff
10:38:33 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 11179346055135384458 (type: WorkingDir, untracked: true)
10:38:33 [TRACE] (1) gitui::app: [src/app.rs:312] update_git: Status
10:38:34 [TRACE] (1) gitui::app: [src/app.rs:228] event: Input(Key(KeyEvent { code: Enter, modifiers: NONE }))
10:38:35 [TRACE] (1) gitui::app: [src/app.rs:228] event: Input(Key(KeyEvent { code: Enter, modifiers: NONE }))
10:38:35 [TRACE] (1) gitui::app: [src/app.rs:228] event: Input(Key(KeyEvent { code: Enter, modifiers: NONE }))
10:38:35 [TRACE] (1) gitui::app: [src/app.rs:228] event: Input(Key(KeyEvent { code: Enter, modifiers: NONE }))
10:38:35 [TRACE] (1) gitui::app: [src/app.rs:294] update
10:38:35 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:90] request
10:38:35 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 12421105405156037469] (type: WorkingDir, untracked: true)
10:38:35 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 8962231771842165632] (type: Stage, untracked: true)
10:38:35 [TRACE] (1) gitui::app: [src/app.rs:312] update_git: Diff
10:38:36 [TRACE] (4) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 8962231771842165632 (type: Stage, untracked: true)
10:38:36 [TRACE] (1) gitui::app: [src/app.rs:312] update_git: Status
10:38:36 [TRACE] (1) gitui::app: [src/app.rs:228] event: Input(Key(KeyEvent { code: Enter, modifiers: NONE }))
10:38:36 [TRACE] (1) gitui::app: [src/app.rs:228] event: Input(Key(KeyEvent { code: Enter, modifiers: NONE }))
10:38:36 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 12421105405156037469 (type: WorkingDir, untracked: true)
10:38:36 [TRACE] (1) gitui::app: [src/app.rs:312] update_git: Status
10:38:36 [TRACE] (1) gitui::app: [src/app.rs:228] event: Input(Key(KeyEvent { code: Enter, modifiers: NONE }))
10:38:36 [TRACE] (1) gitui::app: [src/app.rs:228] event: Input(Key(KeyEvent { code: Enter, modifiers: NONE }))
10:38:36 [TRACE] (1) gitui::app: [src/app.rs:228] event: Input(Key(KeyEvent { code: Enter, modifiers: NONE }))
10:38:37 [TRACE] (1) gitui::app: [src/app.rs:228] event: Input(Key(KeyEvent { code: Char('c'), modifiers: CONTROL }))

@Tony1324
Copy link

Is it that you are using 2 factor authentication on github? i had the same problem and you need to generate a personal access token and enter that instead of your password

@jamesb93
Copy link
Author

Enter that where?

@non-descriptive
Copy link

We don't use 2fa, just regular ssh keys via vpn connection

@matthewp
Copy link

I have to rerun the ssh-add ~/... command every once in a while (every month or so) and i'm not sure why.

@Diablo-D3
Copy link

This is largely a libssh2 issue (it doesn't parse ~/.ssh/config and is an incomplete ssh client implementation due to this). Until this is fixed (either upstream in libssh2, or by gitui dropping the offending dep), the ostensibly 'correct' workaround is:

unset SSH_CONNECTION SSH_TTY && eval $(ssh-agent) && ssh-add ~/.ssh/your_github_key && ~/.cargo/bin/gitui && ssh-agent -k

ssh-agent will not start when you're ssh'd into a box (since an ssh-agent-based workflow would run on the client side, not on the server side), but libssh2 is forcing this incorrect configuration to exist.

@brendon-at-rea
Copy link

A quick note related to libssh2 and ~/.ssh/config: I could never get gitui to push or pull from my work github enterprise. I finally traced it to using a nonstandard ssh port on our service. Git clients that work (CLI, SourceTree, IntelliJ, VSCode) are able to read the port number from the .ssh/config file, whereas gitui fails because it tries to connect to the standard ssh port.

A workaround for me was to use this form when checking out:
ssh://[email protected]:9422/org/repo
so that the port number (9422 in this case) is recorded in the .git/config file.

The result is that I can now push and pull from gitui :)

Thanks for the wonderful tool, by the way!

@ayuayue
Copy link

ayuayue commented Jan 30, 2023

On Windows, you can use the following operations.

  1. open and auto run this services.
    图片
  2. run this command on powershell ssh-add C:\Users\caoayu\.ssh\id_rsa

@aragalie
Copy link

aragalie commented Feb 3, 2023

If you're using the Github CLI gh to setup your machine, it creates by default an ~/.ssh/id_ed25519key using the Ed25519 algorithm instead of the old RSA one. See here https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

This means that for me (Mac M1), the previous ssh-add ~/.ssh/id_rsa suggestion did not work, as there was no RSA key generated in the first place.

So what I did instead in order to get gitui to work (and btw, it also fixed lazygit as well), is ssh-add ~/.ssh/id_ed25519

Basically, pay attention to your exact key ssh key format, and add that one to the ssh agent.

@Abraxos
Copy link

Abraxos commented Feb 14, 2023

A workaround for me was to use this form when checking out: ssh://[email protected]:9422/org/repo so that the port number (9422 in this case) is recorded in the .git/config file.

I was about to add to this bug report, but in doing my due dilligence I did manage to make it work through a combination of the above and adding the relevant SSH key to my SSH-Agent (which may be important since I have a bunch of keys and keep them in a non-standard folder). Leaving this comment mainly to help anyone else who happens to come upon this issue: The solution for me is to use the ssh://[user]@[host]:[port]/path/to/repo.git URL in that exact format, setting all the values, and adding the relevant key to your SSH agent.

@AllenDang
Copy link

I'm still experience this issue on macOS v13.2, I followed every steps in https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent and issue still there.

Here is the log

14:37:17 [INFO] push: branch 'master' has upstream for remote 'origin' - using that
14:37:17 [TRACE] (1) asyncgit::push: [asyncgit/src/push.rs:82] request
14:37:17 [INFO] [Debug]: Sending GET request to https://github.com/AllenDang/nvimconfig/info/refs?service=git-receive-pack
14:37:17 [INFO] [Debug]: Connecting to proxy 127.0.0.1 port 7890
14:37:17 [INFO] [Trace]: Sending request:
CONNECT github.com:443 HTTP/1.1
User-Agent: git/2.0 (libgit2 1.5.0)
Host: github.com:443


14:37:17 [INFO] [Trace]: Received:
HTTP/1.1 200 Connection established


14:37:17 [INFO] [Debug]: Connecting to remote github.com port 443
14:37:17 [INFO] [Trace]: Sending request:
GET /AllenDang/nvimconfig/info/refs?service=git-receive-pack HTTP/1.1
User-Agent: git/2.0 (libgit2 1.5.0)
Host: github.com
Accept: */*


14:37:17 [INFO] [Trace]: Received:
HTTP/1.1 401 Unauthorized
Server: GitHub-Babel/3.0
Content-Security-Policy: default-src 'none'; sandbox
Content-Type: text/plain; charset=UTF-8
www-authenticate: Basic realm="GitHub"
Content-Length: 21
Date: Mon, 20 Mar 2023 14:37:17 GMT
X-Frame-Options: DENY
X-GitHub-Request-Id: 96C7:12B5:D0DAF0:DFEA5B:64186F9D

Repository not found.
14:37:17 [DEBUG] (11) asyncgit::sync::remotes::callbacks: creds: 'https://github.com/AllenDang/nvimconfig' None (USER_PASS_PLAINTEXT)
14:37:17 [INFO] [Debug]: Sending GET request to https://github.com/AllenDang/nvimconfig/info/refs?service=git-receive-pack
14:37:17 [INFO] [Trace]: Sending request:
GET /AllenDang/nvimconfig/info/refs?service=git-receive-pack HTTP/1.1
User-Agent: git/2.0 (libgit2 1.5.0)
Host: github.com
Accept: */*
Authorization: Basic QWxsZW5EYW5nOkFsbGVuLjhEZQ==


14:37:18 [INFO] [Trace]: Received:
HTTP/1.1 401 Unauthorized
Server: GitHub-Babel/3.0
Content-Security-Policy: default-src 'none'; sandbox
Content-Type: text/plain; charset=UTF-8
www-authenticate: Basic realm="GitHub"
Content-Length: 259
Date: Mon, 20 Mar 2023 14:37:17 GMT
X-Frame-Options: DENY
X-GitHub-Request-Id: 96C7:12B5:D0DB2F:DFEAB5:64186F9D

Support for password authentication was removed on August 13, 2021.
Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.

14:37:18 [DEBUG] (11) asyncgit::sync::remotes::callbacks: creds: 'https://github.com/AllenDang/nvimconfig' None (USER_PASS_PLAINTEXT)
14:37:18 [TRACE] (1) gitui::app: [src/app.rs:496] update_async: Git(Push)
14:37:18 [ERROR] push error: git error:Bad credentials.
14:37:18 [TRACE] (1) gitui::app: [src/app.rs:477] update
14:37:18 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 15108723405112716490] (type: WorkingDir)
14:37:18 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 14771609772487905132] (type: Stage)
14:37:18 [TRACE] (4) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 14771609772487905132 (type: Stage)
14:37:18 [TRACE] (2) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 15108723405112716490 (type: WorkingDir)
14:37:18 [TRACE] (1) gitui::app: [src/app.rs:496] update_async: Git(Push)
14:37:18 [TRACE] (1) gitui::app: [src/app.rs:496] update_async: Git(Status)
14:37:18 [TRACE] (1) gitui::app: [src/app.rs:496] update_async: Git(Status)
14:37:20 [TRACE] (1) gitui::app: [src/app.rs:382] event: Input(Key(KeyEvent { code: Enter, modifiers: NONE, kind: Press, state: NONE }))
14:37:20 [TRACE] (1) gitui::app: [src/app.rs:382] event: Input(Key(KeyEvent { code: Char('q'), modifiers: NONE, kind: Press, state: NONE }))

@burgessa23
Copy link

burgessa23 commented Apr 21, 2023

if I have a remote like [email protected]:org/my-repo.git is that going to cause issues? I verified the ssh-agent but the app just hangs until I force quit if I try to fetch an existing repo:

   1   │ 05:02:38 [TRACE] (6) mio::poll: [/Users/brew/Library/Caches/Homebrew/cargo_cache/registry/src/github.com-1ecc6299db9ec823/mio-0.8.5/src/poll.rs:532] registering event source with poller:
       │  token=Token(0), interests=READABLE
   2   │ 05:02:38 [TRACE] (6) mio::poll: [/Users/brew/Library/Caches/Homebrew/cargo_cache/registry/src/github.com-1ecc6299db9ec823/mio-0.8.5/src/poll.rs:532] registering event source with poller:
       │  token=Token(1), interests=READABLE
   3   │ 05:02:38 [TRACE] (1) gitui::watcher: [src/watcher.rs:21] poll watcher: false recommended: Fsevent
   4   │ 05:02:38 [TRACE] (1) gitui::app: [src/app.rs:119] open repo at: RefCell { value: Path(".") }
   5   │ 05:02:38 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 17634073806937891559] (type: WorkingDir)
   6   │ 05:02:38 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 10513360875755911950] (type: Stage)
   7   │ 05:02:38 [TRACE] (1) gitui: [src/main.rs:200] app start: 10 ms
   8   │ 05:02:38 [TRACE] (1) gitui::app: [src/app.rs:477] update
   9   │ 05:02:38 [TRACE] (4) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 10513360875755911950 (type: Stage)
  10   │ 05:02:38 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:96] request blocked, still pending
  11   │ 05:02:38 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 3660099711082137495] (type: Stage)
  12   │ 05:02:38 [TRACE] (2) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 3660099711082137495 (type: Stage)
  13   │ 05:02:38 [TRACE] (1) gitui::app: [src/app.rs:496] update_async: Git(Branches)
  14   │ 05:02:38 [TRACE] (1) gitui::app: [src/app.rs:496] update_async: Git(Status)
  15   │ 05:02:38 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 17634073806937891559 (type: WorkingDir)
  16   │ 05:02:38 [TRACE] (1) gitui::app: [src/app.rs:496] update_async: Git(Status)
  17   │ 05:02:38 [TRACE] (1) gitui::app: [src/app.rs:496] update_async: Git(Status)
  18   │ 05:02:40 [DEBUG] (8) gitui::watcher: notify events: 1
  19   │ 05:02:40 [DEBUG] (8) gitui::watcher: notify [0]: DebouncedEvent { path: "/REDACTED/.git/gitui", kind: Any }
  20   │ 05:02:40 [TRACE] (1) gitui::app: [src/app.rs:477] update
  21   │ 05:02:40 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 7728542056205355979] (type: WorkingDir)
  22   │ 05:02:40 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 13146885645116400871] (type: Stage)
  23   │ 05:02:40 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 13146885645116400871 (type: Stage)
  24   │ 05:02:40 [TRACE] (1) gitui::app: [src/app.rs:496] update_async: Git(Status)
  25   │ 05:02:40 [TRACE] (2) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 7728542056205355979 (type: WorkingDir)
  26   │ 05:02:40 [TRACE] (1) gitui::app: [src/app.rs:496] update_async: Git(Status)
  27   │ 05:02:41 [TRACE] (1) gitui::app: [src/app.rs:382] event: Input(Key(KeyEvent { code: Char('f'), modifiers: NONE, kind: Press, state: NONE }))
  28   │ 05:02:41 [TRACE] (1) asyncgit::pull: [asyncgit/src/pull.rs:75] request
  29   │ 05:02:41 [TRACE] (1) gitui::app: [src/app.rs:477] update
  30   │ 05:02:41 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 4149439348256024951] (type: WorkingDir)
  31   │ 05:02:41 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 13189008663216841880] (type: Stage)
  32   │ 05:02:41 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 13189008663216841880 (type: Stage)
  33   │ 05:02:41 [TRACE] (1) gitui::app: [src/app.rs:496] update_async: Git(Status)
  34   │ 05:02:41 [TRACE] (2) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 4149439348256024951 (type: WorkingDir)
  35   │ 05:02:41 [TRACE] (1) gitui::app: [src/app.rs:496] update_async: Git(Status)
  36   │ 05:07:08 [TRACE] (1) gitui::app: [src/app.rs:382] event: Input(Key(KeyEvent { code: Char('c'), modifiers: CONTROL, kind: Press, state: NONE }))

Note the ~5 minutes of nothing in the log between lines 35 & 36
The UI just stays static with:
image

@eggcaker
Copy link

eggcaker commented Jul 4, 2023

On Windows11 , after started OpenSSH Authentication Agent service , and run ssh-add ~/.ssh/id_rsa fixed .

@abdelrahman-essawy
Copy link

On Windows11 , after started OpenSSH Authentication Agent service , and run ssh-add ~/.ssh/id_rsa fixed .

this worked for me, thank you.
here is guide to enable openSSH on windows

@tyoc213
Copy link

tyoc213 commented Aug 7, 2023

ssh-add ~/.ssh/id_rsa also worked for same problem on osx... but why if git push on same directory will work???

@non-descriptive
Copy link

but why if git push on same directory will work???

git-push figures out this from os environment and overall has complicated resolution logic as for general ssh connections as for commit signing. AFAIK it wasn't implemented yet inside underlying library on the rust side so it's impossible to do the same what regular git does. That's require some expertise in a field and that's why this issue marked as help wanted.

@DreckSallow
Copy link

DreckSallow commented Aug 10, 2023

Do you think it will be possible to add a popup to add the password to push?

@RilDev
Copy link

RilDev commented Aug 14, 2023

Maybe you could try this to manage multiple Git Identities: https://github.com/InderdeepBajwa/gitid

@rootex-
Copy link

rootex- commented Nov 22, 2023

@extrawurst the problem still persists. In the past I had no pushing problems with gitui. Looks like the problem has returned with the some latest changes.

@tmpgnh
Copy link

tmpgnh commented Nov 24, 2023

@extrawurst the problem still persists. In the past I had no pushing problems with gitui. Looks like the problem has returned with the some latest changes.

Same here, on a Linux box:

% gitui --version
gitui 0.24.3
% ssh-agent -k
% eval $(ssh-agent)
% ssh-add ~/.ssh/id_ed25519
% ssh-add -l
256 SHA256:... user@host (ED25519)
# a single entry
% gitui -l
# Then push (press 'p')
% cat ~/.cache/gitui/gitui.log
10:03:55 [TRACE] (1) gitui::app: [src/app.rs:123] open repo at: RefCell { value: Path(".") }
10:03:55 [TRACE] (6) mio::poll: [/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.5/src/poll.rs:532] registering event source with poller: token=Token(0), interests=READABLE
10:03:55 [TRACE] (6) mio::poll: [/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.5/src/poll.rs:532] registering event source with poller: token=Token(1), interests=READABLE
10:03:55 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 7003927015617394622] (type: WorkingDir)
10:03:55 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 7177724718573686462] (type: Stage)
10:03:55 [TRACE] (5) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 7177724718573686462 (type: Stage)
10:03:55 [TRACE] (1) gitui: [src/main.rs:216] app start: 32 ms
10:03:55 [TRACE] (1) gitui::app: [src/app.rs:497] update
10:03:55 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:96] request blocked, still pending
10:03:55 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 7020450438269687951] (type: Stage)
10:03:55 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 7003927015617394622 (type: WorkingDir)
10:03:55 [TRACE] (2) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 7020450438269687951 (type: Stage)
10:03:55 [TRACE] (1) gitui::app: [src/app.rs:517] update_async: Git(Status)
10:03:55 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:98] request DiffParams { path: ".gitignore", diff_type: WorkDir, options: DiffOptions { ignore_whitespace: false, context: 3, interhunk_lines: 0 } }
10:03:55 [TRACE] (1) gitui::app: [src/app.rs:517] update_async: Git(Branches)
10:03:55 [TRACE] (1) gitui::app: [src/app.rs:517] update_async: Git(Status)
10:03:55 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:98] request DiffParams { path: ".gitignore", diff_type: WorkDir, options: DiffOptions { ignore_whitespace: false, context: 3, interhunk_lines: 0 } }
10:03:55 [TRACE] (1) gitui::app: [src/app.rs:517] update_async: Git(Status)
10:03:55 [TRACE] (1) gitui::app: [src/app.rs:517] update_async: Git(Diff)
10:03:56 [TRACE] (1) gitui::app: [src/app.rs:400] event: Input(Key(KeyEvent { code: Char('p'), modifiers: NONE, kind: Press, state: NONE }))
10:03:56 [INFO] push: branch '...' has no upstream - looking up default remote
10:03:56 [INFO] push: branch '...' to remote 'origin'
10:03:56 [TRACE] (1) asyncgit::push: [asyncgit/src/push.rs:82] request
10:03:56 [TRACE] (1) gitui::app: [src/app.rs:497] update
10:03:56 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:98] request DiffParams { path: ".gitignore", diff_type: WorkDir, options: DiffOptions { ignore_whitespace: false, context: 3, interhunk_lines: 0 } }
10:03:56 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 17309418712830783626] (type: WorkingDir)
10:03:56 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 1663522749782520975] (type: Stage)
10:03:56 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 1663522749782520975 (type: Stage)
10:03:56 [TRACE] (1) gitui::app: [src/app.rs:517] update_async: Git(Diff)
10:03:56 [TRACE] (4) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 17309418712830783626 (type: WorkingDir)
10:03:56 [TRACE] (1) gitui::app: [src/app.rs:517] update_async: Git(Status)
10:03:56 [TRACE] (1) gitui::app: [src/app.rs:517] update_async: Git(Status)
10:03:56 [ERROR] push error: git error:failed to start SSH session: Unable to exchange encryption keys; class=Ssh (23)
10:03:56 [TRACE] (1) gitui::app: [src/app.rs:517] update_async: Git(Push)
10:03:56 [TRACE] (1) gitui::app: [src/app.rs:497] update
10:03:56 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:98] request DiffParams { path: ".gitignore", diff_type: WorkDir, options: DiffOptions { ignore_whitespace: false, context: 3, interhunk_lines: 0 } }
10:03:56 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 16374901233706118069] (type: WorkingDir)
10:03:56 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:102] request: [hash: 13765958480891183974] (type: Stage)
10:03:56 [TRACE] (5) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 13765958480891183974 (type: Stage)
10:03:56 [TRACE] (4) asyncgit::status: [asyncgit/src/status.rs:160] status fetched: 16374901233706118069 (type: WorkingDir)
10:03:56 [TRACE] (1) gitui::app: [src/app.rs:517] update_async: Git(Push)
10:03:56 [TRACE] (1) gitui::app: [src/app.rs:517] update_async: Git(Diff)
10:03:56 [TRACE] (1) gitui::app: [src/app.rs:517] update_async: Git(Status)
10:03:56 [TRACE] (1) gitui::app: [src/app.rs:517] update_async: Git(Status)
10:03:58 [TRACE] (1) gitui::app: [src/app.rs:400] event: Input(Key(KeyEvent { code: Char('c'), modifiers: CONTROL, kind: Press, state: NONE }))

@cd-a
Copy link

cd-a commented Dec 17, 2023

any update on this? this is the only issue that keeps me from switching from lazygit

@Zhoujinpeng1999
Copy link

This is largely a libssh2 issue (it doesn't parse ~/.ssh/config and is an incomplete ssh client implementation due to this). Until this is fixed (either upstream in libssh2, or by gitui dropping the offending dep), the ostensibly 'correct' workaround is:

unset SSH_CONNECTION SSH_TTY && eval $(ssh-agent) && ssh-add ~/.ssh/your_github_key && ~/.cargo/bin/gitui && ssh-agent -k

ssh-agent will not start when you're ssh'd into a box (since an ssh-agent-based workflow would run on the client side, not on the server side), but libssh2 is forcing this incorrect configuration to exist.

This worked for me, and I created an alias for gitui in zshrc.
alias 'gitui'='eval $(ssh-agent) && ssh-add ~/.ssh/id_ed25519 && gitui'

@Abraxos
Copy link

Abraxos commented Mar 14, 2024

This is largely a libssh2 issue (it doesn't parse ~/.ssh/config and is an incomplete ssh client implementation due to this). Until this is fixed (either upstream in libssh2, or by gitui dropping the offending dep), the ostensibly 'correct' workaround is:
unset SSH_CONNECTION SSH_TTY && eval $(ssh-agent) && ssh-add ~/.ssh/your_github_key && ~/.cargo/bin/gitui && ssh-agent -k
ssh-agent will not start when you're ssh'd into a box (since an ssh-agent-based workflow would run on the client side, not on the server side), but libssh2 is forcing this incorrect configuration to exist.

This worked for me, and I created an alias for gitui in zshrc. alias 'gitui'='eval $(ssh-agent) && ssh-add ~/.ssh/id_ed25519 && gitui'

I just came here to say this was super helpful, I both understood and the problem and the workaround is confirmed good! The only thing is that on my mac I had to modify it slightly (haven't tried it on Linux yet): alias gitui="eval '$(ssh-agent)' && ssh-add ~/.ssh/id_ed25519 && gitui" (note the different quotes).

Thank you!

@apraga
Copy link

apraga commented Mar 29, 2024

Adapting the workaround to nushell (there's no eval available unfortunately, using this workaround to avoid spawning many ssh-agent processs) : put in ~/.config/nushell/config.nu

def mygitui [] {
    do --env {
        let ssh_agent_file = (
            $nu.temp-path | path join $"ssh-agent-($env.USER?).nuon"
        )

        if ($ssh_agent_file | path exists) {
            let ssh_agent_env = open ($ssh_agent_file)
            if ($"/proc/($ssh_agent_env.SSH_AGENT_PID)" | path exists) {
                load-env $ssh_agent_env
                return
            } else {
                rm $ssh_agent_file
            }
        }

        let ssh_agent_env = ^ssh-agent -c
            | lines
            | first 2
            | parse "setenv {name} {value};"
            | transpose --header-row
            | into record
        load-env $ssh_agent_env
        $ssh_agent_env | save --force $ssh_agent_file
        }
    ssh-add ~/.ssh/id_rsa
    gitui
    }
alias gt = mygitui

Using a function is necessary at the moment according to nushell/nushell#10088.

@kyruzic
Copy link

kyruzic commented Apr 22, 2024

If you are using a systemd based distro don't mess around with trying to get your shell to auto start ssh-agent and run ssh-add

Just create a user service that does that

to do just create a file ~/.config/systemd/user/ssh-agent.service

and put this as the file content

[Unit]
Description=SSH key agent

[Service]
Type=simple
Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
Environment=KEY_FILE=/home/%u/.ssh/{REPLACE_WITH_YOUR_SSH_KEY_FILENAME}
ExecStart=/usr/bin/ssh-agent -D -a $SSH_AUTH_SOCK
ExecStartPost=/usr/bin/ssh-add $KEY_FILE
ExecStop=kill -15 $MAINPID

[Install]
WantedBy=default.target

Then start and enable the service with

systemctl --user enable --now ssh-agent.service

This will prevent creating multiple instances of the ssh-agent and works independent of whatever shell you use.

@Zhoujinpeng1999
Copy link

If you are using a systemd based distro don't mess around with trying to get your shell to auto start ssh-agent and run ssh-add

Just create a user service that does that

to do just create a file ~/.config/systemd/user/ssh-agent.service

and put this as the file content

[Unit]
Description=SSH key agent

[Service]
Type=simple
Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
Environment=KEY_FILE=/home/%u/.ssh/{REPLACE_WITH_YOUR_SSH_KEY_FILENAME}
ExecStart=/usr/bin/ssh-agent -D -a $SSH_AUTH_SOCK
ExecStartPost=/usr/bin/ssh-add $KEY_FILE
ExecStop=kill -15 $MAINPID

[Install]
WantedBy=default.target

Then start and enable the service with

systemctl --user enable --now ssh-agent.service

This will prevent creating multiple instances of the ssh-agent and works independent of whatever shell you use.

I thought it was a good practice and tried it, but I'm sorry it didn't work for me. I'm not sure why, but it made me find that my previous command would start multiple ssh-agent but not destroy them.The right thing to do is to destroy the ssh-agent after the end of the gitui. The modified command should look like this.

alias 'gitui'='eval $(ssh-agent) && ssh-add ~/.ssh/id_ed25519 && gitui && ssh-agent -k'

-k means kill the current agent (given by the SSH_AGENT_PID environment variable).
More information about ssh-agent can be found at man ssh-agent.

@apraga
Copy link

apraga commented Apr 28, 2024

@kyruzic Thanks for the feedback. Your approach works in nushell if we also set $env.SSH_AUTH_SOCK = $"($env.XDG_RUNTIME_DIR)/ssh-agent.socket" (taken from https://www.nushell.sh/cookbook/ssh_agent.html#non-nushell-workarounds ).

@fgimian
Copy link

fgimian commented Aug 25, 2024

2. powershell

I have verified this solution here too, although I only have the OpenSSH Authentication Agent service listed. Starting that seems to be all that's needed along with ssh-add.

Cheers
Fotis

@Martan404
Copy link

Martan404 commented Aug 28, 2024

You can add this to your .bashrc to use as gitui-ssh command (I'm not a bash developer, but seems it works):

gitui-ssh() {
  key="${1:-$HOME/.ssh/id_rsa}"
  eval "$(ssh-agent)" \
    && ssh-add "$key" \
    && gitui "${@:2}" \
    && eval "$(ssh-agent -k)"
}

This solution works for me! Except that I had to change the command to

gitui-ssh() {
  key="${1:-$HOME/.ssh/id_rsa}"
  eval "$(ssh-agent)" \
    && ssh-add "$key" \
    && command gitui "${@:2}" \
    && eval "$(ssh-agent -k)"
}

@Sammmmm
Copy link

Sammmmm commented Nov 18, 2024

git config --global credential.helper store worked for me when git push worked but gitui did not

@Zeonova
Copy link

Zeonova commented Nov 25, 2024

On Windows11 , after started OpenSSH Authentication Agent service , and run ssh-add ~/.ssh/id_rsa fixed .

On Mac, need run 'ssh-add --apple-use-keychain ~/.ssh/id_rsa', You need to do this every time the terminal restarts.
use 'ssh-add -l' to view the key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed windows
Projects
None yet
Development

No branches or pull requests