`jj git push` is not working for me on Windows
Description
whenever i run jj git push, i get one of the two errors:
- on WSL:
Error: invalid or unknown remote ssh hostkey; class=Ssh (23); code=Certificate (-17) - on Windows:
Error: failed to set hostkey preference: The requested method(s) are not currently supported; class=Ssh (23)
Steps to Reproduce the Problem
i have no idea. i don't believe this is related to my .ssh/config, since ssh -F /dev/null [email protected] succeeds. i have the following env variables set on WSL:
; set | grep '^SSH'
SSH_AGENT_PID=48
SSH_AUTH_SOCK=/tmp/ssh-XXXXXXzGR8a4/agent.47
those aren't set on windows, but ssh-agent is somehow working anyway; at least, ssh-add succeeds.
Expected Behavior
jj is able to push to the remote.
Specifications
- Platform: Linux windows-desktop 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
- Windows 11 Pro 22621.3296
- Version: jj 0.15.1-bf76080f42f77cad934d9a5202c7b7d29ab2c890 (although this also happened with 0.14)
the second one might be https://github.com/libgit2/libgit2/issues/6612 iirc i’ve worked around this in the past by ensuring my known_hosts does not contain an ed25519 key for github
I am getting the same issue on windows (not WSL):
PS D:\repos\LeadLens> jj git push -c "@-"
Creating branch push-nroqnvwmpzqn for revision @-
Branch changes to push to origin:
Add branch push-nroqnvwmpzqn to e06c042721af
Error: Failed to authenticate SSH session: ; class=Ssh (23)
Hint: Jujutsu uses libssh2, which doesn't respect ~/.ssh/config. Does `ssh -F /dev/null` to the host work?
Similar issue here; I am cloning a repository from a private GitLab service using Windows and the remote ssh key is ed25519, and getting "Error: Fetch failed: failed to set hostkey preference: The requested method(s) are not currently supported; class=Ssh (23)". If I comment out the known_hosts line, I instead get "Fetch failed: failed to start SSH session: Unable to exchange encryption keys; class=Ssh (23)"
libssh2 error code 23 is LIBSSH2_ERROR_CHANNEL_UNKNOWN which is either "Packet received for unknown channel" or "Channel not found". That's really strange. This seems to affect jj all the way back to 0.7 (which was what cargo installed for some reason). Is libgit2 doing something it shouldn't?
I've tracked down the issue. The Windows Cryptography Next Generation API backend for libssh2 do not have support for ED25519 and libssh2-sys is defaulting to use it instead of OpenSSL when targeting win32 (either msvc or mingw). libssh2-sys must be compiled with the openssl-on-win32 feature (and vendored-openssl) in order to use the OpenSSL backend.
All distributions of git on windows use a combination of cygwin and git itself which are all compiled to use openssl, which is why it's not a common issue for windows git users. But when using libgit2 directly, this is something to be conscientious of I guess.
This is also a problem for me, trying to interact with Gitlab. I've installed jj with winget and am on version 0.23.0.
This is what I get in a colocated repo, trying to jj git fetch.
With an empty known_hosts file:
Error: invalid or unknown remote ssh hostkey; class=Ssh (23); code=Certificate (-17)
Hint: The HOME environment variable is not set, and might be required for Git to successfully load certificates. Try setting it to the path of a directory that contains a `.ssh` directory.
With ED25519, which is the default with git:
Error: failed to set hostkey preference: The requested method(s) are not currently supported; class=Ssh (23)
Hint: Jujutsu uses libssh2, which doesn't respect ~/.ssh/config. Does `ssh -F /dev/null` to the host work?
I've tried to use a different hostkey algorithm by running ssh -o HostKeyAlgorithms=ssh-rsa "[email protected]". After running that, I get:
Error: failed to authenticate SSH session: ; class=Ssh (23)
Hint: Jujutsu uses libssh2, which doesn't respect ~/.ssh/config. Does `ssh -F /dev/null` to the host work?
I run into the same issue on NixOS 25.05.20250303 with an ED25519 key
❯ jj git push
Changes to push to origin:
Add bookmark trunk to b1ef2c9da0d4
Error: invalid or unknown remote ssh hostkey; class=Ssh (23); code=Certificate (-17)
Hint: Jujutsu uses libssh2, which doesn't respect ~/.ssh/config. Does `ssh -F /dev/null` to the host work?
ops in ~/source/ratatui-test via ❄️ impure (devenv-shell-env)
❯ ssh -F /dev/null gitlab.com
[email protected]: Permission denied (publickey).
Is there another way to pass the arguments specified in ~/.ssh/config?
Have you tried this with git.subprocess = true in jj 0.26 or with jj 0.27 (which sets this option by default)? 🤞 it should be just the ticket.
https://jj-vcs.github.io/jj/latest/config/#git-subprocessing-behaviour (these are 0.27 docs)
@ilyagr Thanks a lot. That worked 🚀