jj icon indicating copy to clipboard operation
jj copied to clipboard

SSH authentication prompt causes jj to hang

Open cwfitzgerald opened this issue 5 months ago • 4 comments

Description

I've tried to look through the variety of ssh related issues. I didn't find one that obviously mapped to this exact problem, so I'm going to report it, but feel free to de-dupe if this is internally a dupe.

When connecting to a ssh host for the first time, you get a notification from ssh to confirm that you want to continue connecting to the host.

$ jj --debug git fetch --remote my_remote
2025-06-12T01:32:41.381056Z  INFO jj_cli::cli_util: debug logging enabled
2025-06-12T01:32:41.446916Z DEBUG run_command:cmd_git_fetch:fetch{remote_name=RemoteName("my_remote") branch_names=[Glob(GlobPattern("*"))] depth=None}: jj_lib::git_subprocess: spawning a git subprocess cmd="git" "--git-dir" "C:\\Users\\conno\\Programming\\wgpu\\.git" "fetch" "--prune" "--no-write-fetch-head" "--progress" "--" "my_remote" "+refs/heads/*:refs/remotes/my_remote/*"

<hangs indefinitely>
$ git fetch my_remote
The authenticity of host 'ssh.github.com (140.82.114.35)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This host key is known by the following other names/addresses:
    C:\Users\conno/.ssh/known_hosts:1: github.com
Are you sure you want to continue connecting (yes/no/[fingerprint])?
Warning: Permanently added 'ssh.github.com' (ED25519) to the list of known hosts.

Steps to Reproduce the Problem

  1. Remove ssh.github.com/github.com from your known hosts
  2. Try to pull from a remote using that address.
  3. See hang

Expected Behavior

Either an clear error message or the ssh prompt.

Actual Behavior

Hang.

Specifications

  • Platform: Windows 11, x86_64
  • Version: On a fork of 4-5 day old main, to get https://github.com/jj-vcs/jj/pull/6036 early.

cwfitzgerald avatar Jun 12 '25 01:06 cwfitzgerald

This sounds vaguely similar to https://github.com/jj-vcs/jj/issues/6568 (though that one mentions pushing but not fetching)

cole-h avatar Jun 12 '25 04:06 cole-h

This is quite similar to https://github.com/jj-vcs/jj/issues/5924, but went to the different way. In #5924, ssh appeared to fail at accessing the tty. In this issue, ssh would fail to notice that the stdin isn't a tty.

yuja avatar Jun 12 '25 09:06 yuja

I've got the exact same issue, except that if I try it twice, I get a lock file error:

Administrator in jujutsu-2 on  HEAD (8543dce) on ☁️  (sa-east-1) took 12s
❯ jj --debug commit -m "test ssh key"
2025-06-19T00:13:34.393919Z  INFO jj_cli::cli_util: debug logging enabled
2025-06-19T00:13:34.453219Z  INFO run_command:cmd_commit: jj_lib::ssh_signing: running SSH signing command command="ssh-keygen" "-Y" "sign" "-f" "C:\\Users\\Cliente\\.ssh/id_ed25519.pub" "-n" "git"
-- Hangs --

Administrator in jujutsu-2 on  HEAD (8543dce) [?] on ☁️  (sa-east-1)
❯ jj --debug commit -m "test ssh key"
2025-06-19T00:18:25.092331Z  INFO jj_cli::cli_util: debug logging enabled
Internal error: Failed to access working copy state
Caused by:
1: Failed to lock working copy
2: Timed out while trying to create lock file: C:\Users\Cliente\Documents\Projects\Jujutsu\jujutsu-2\.jj\working_copy\working_copy.lock
3: The file exists. (os error 80)

Platform: Windows 11 24H2 Version: jj 0.30.0-34b0961c940e1ad3be5cd9c5f5e608b0aa0ba859

Doomwhite avatar Jun 19 '25 00:06 Doomwhite

For the record, I also get this problem - I just figured it was a byproduct of interrupting jj in a hang and deleted the lock file.

cwfitzgerald avatar Jun 20 '25 04:06 cwfitzgerald

PS D:\luin> jj --debug commit -m "test ssh key"
2025-07-06T22:50:56.477936Z  INFO jj_cli::cli_util: debug logging enabled
Internal error: Unexpected error from backend
Caused by:
1: Failed to read non-git metadata
2: Failed to lock table store
3: Timed out while trying to create lock file: D:\luin\.jj\repo\store\extra\lock
4: The file exists. (os error 80)
PS D:\luin> jj version
jj 0.31.0-312c610c592b41ec81f0661e124fd660cb510ab0

I believe the error that I am getting is related to this. I can get by the above error if I delete D:\luin\.jj\repo\store\extra\lock and the command works as expected. Running jj git push gives me the same error as above, but deleting D:\luin\.jj\repo\store\extra\lock doesn't make it run successfully, it just hangs on the SSH signing command forever.

Before deleting D:\luin\.jj\repo\store\extra\lock :

PS D:\luin> jj git push --allow-new --debug
2025-07-06T22:54:45.537016Z  INFO jj_cli::cli_util: debug logging enabled
Internal error: Unexpected error from backend
Caused by:
1: Failed to read non-git metadata
2: Failed to lock table store
3: Timed out while trying to create lock file: D:\luin\.jj\repo\store\extra\lock
4: The file exists. (os error 80)

After deleting D:\luin\.jj\repo\store\extra\lock :

PS D:\luin> jj git push --allow-new --debug
2025-07-06T22:54:42.418057Z  INFO jj_cli::cli_util: debug logging enabled
2025-07-06T22:54:42.451484Z  INFO run_command: jj_lib::ssh_signing: running SSH signing command command="ssh-keygen" "-Y" "sign" "-f" "C:/Users/haugen/.ssh/id_ed25519.pub" "-n" "git"

I can confirm that the original report works properly now, so I suspect the move to the git binary for this stuff has fixed this issue.

steveklabnik avatar Dec 03 '25 16:12 steveklabnik

I can confirm that the original report works properly now, so I suspect the move to the git binary for this stuff has fixed this issue.

You mean on Windows? There might be bad combination of Windows git/ssh and terminal. The underlying git/ssh process has to get the tty without relying on stdio.

yuja avatar Dec 04 '25 01:12 yuja