-
-
Notifications
You must be signed in to change notification settings - Fork 270
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
SSH host verification fails when IP changes (git succeeds) #2334
Comments
Fixes #38777. Might fix JuliaLang/Pkg.jl#2334. It seems likely no one actually verifies SSH host identity with libgit2 because the callback doesn't give enough information do so correctly: - It doesn't give the actual host key fingerprint, but rather three different hashes thereof; this means we cannot distinguish a known hosts entry that has a different type (`ssh-rsa`, `ssh-dsa`, etc.) versus an entry with a matching type and a fingerprint mismatch. The former should be treated as an unknown host whereas the latter is a host key mismatch; they cananot be distinguished with this patch. - If the user connects on a non-default port (i.e. not 22), this is not passed to the callback in any way. Since there can be different known host entries for different ports and they should be treated as distinct, this also means the current API cannot be used to verify hosts serving SSH on non-standard ports. This patch passes the port. I will try to upstream some version of this patch to libgit2. The same patch has already been applied to the LibGit2 JLL.
Fixes #38777. Might fix JuliaLang/Pkg.jl#2334. It seems likely no one actually verifies SSH host identity with libgit2 because the callback doesn't give enough information do so correctly: - It doesn't give the actual host key fingerprint, but rather three different hashes thereof; this means we cannot distinguish a known hosts entry that has a different type (`ssh-rsa`, `ssh-dsa`, etc.) versus an entry with a matching type and a fingerprint mismatch. The former should be treated as an unknown host whereas the latter is a host key mismatch; they cananot be distinguished with this patch. - If the user connects on a non-default port (i.e. not 22), this is not passed to the callback in any way. Since there can be different known host entries for different ports and they should be treated as distinct, this also means the current API cannot be used to verify hosts serving SSH on non-standard ports. This patch passes the port. I will try to upstream some version of this patch to libgit2. The same patch has already been applied to the LibGit2 JLL.
@iamed2: if you could please check if this fixes the issue with your server, that would be appreciated. |
I'm getting a segfault now
Happens even in the scenario where the correct keys are present, or when no keys are present. I ran
|
Ah yeah looks like I need to do something else as |
Nope, it downloaded |
Maybe try |
I did a full clean build with |
The version used by |
It seems that no one actually verifies SSH host identity with libgit2 because the callback doesn't give enough information do so correctly: - It doesn't give the actual host key fingerprint, but rather three different hashes thereof. This means we cannot distinguish a known hosts entry that has a different type (`ssh-rsa`, `ssh-dsa`, etc.) from an entry with a matching type and a fingerprint mismatch: the former should be treated as an unknown host whereas the latter is a host key mismatch; they cannot be distinguished without this patch. - If the user connects on a non-default port (i.e. not 22), this is not passed to the callback in any way. Since there can be different known host entries for different ports and they should be treated as distinct, this also means the current API cannot be used to verify hosts serving SSH on non-standard ports. This patch passes the port. I will try to upstream some version of this patch to libgit2. The same patch has already been applied to the LibGit2 JLL. Fixes #38777. Might fix JuliaLang/Pkg.jl#2334. (cherry picked from commit 2b13234)
I found a slack message thanks to Mose that says this has changed and specifically LibGit2 was changed to have a greater version. |
This was broken when the git URL used the |
G1 then updating the registry (no IP change) no longer works. In addition, it throws an
|
Hmm, this one is because because git only records the |
I think in this case it's wrong to say |
If you use |
What is libssh2 telling you in this case? Are you getting I'd really like to see the error message in this case suggest running |
Hmmm, libssh2 should support the modern keys as of version 1.9, but only with OpenSSL: https://www.libssh2.org/changes.html I guess that won't work since we use MbedTLS? The MbedTLS version supports ecdsa as of libssh2/libssh2#385 but that hasn't been released yet AFAICT. |
Yes. You can see the logic here: If that error message gets printed then
Yes, we use MbedTLS. We could probably switch to OpenSSL, although I'm not sure about the license compatibility. Personally ain't doing all that and it's way too late to be switching TLS engines for the 1.6 release.
Great, I guess this problem will fix itself when the make a new release. Can you confirm if using |
Yes, both of those work. |
It also successfully verifies when the IP changes (if I manually test with the ssh-rsa key and a changing IP), so this issue is technically resolved. |
If you want to, you can open an issue on https://github.com/JuliaLang/julia about libgit2 not supporting |
I'll do both! |
It seems that no one actually verifies SSH host identity with libgit2 because the callback doesn't give enough information do so correctly: - It doesn't give the actual host key fingerprint, but rather three different hashes thereof. This means we cannot distinguish a known hosts entry that has a different type (`ssh-rsa`, `ssh-dsa`, etc.) from an entry with a matching type and a fingerprint mismatch: the former should be treated as an unknown host whereas the latter is a host key mismatch; they cannot be distinguished without this patch. - If the user connects on a non-default port (i.e. not 22), this is not passed to the callback in any way. Since there can be different known host entries for different ports and they should be treated as distinct, this also means the current API cannot be used to verify hosts serving SSH on non-standard ports. This patch passes the port. I will try to upstream some version of this patch to libgit2. The same patch has already been applied to the LibGit2 JLL. Fixes #38777. Might fix JuliaLang/Pkg.jl#2334. (cherry picked from commit 2b13234)
This comment has been minimized.
This comment has been minimized.
I might be experiencing the issue here. I had opened an issue at: #2428
|
…ang#39324) It seems that no one actually verifies SSH host identity with libgit2 because the callback doesn't give enough information do so correctly: - It doesn't give the actual host key fingerprint, but rather three different hashes thereof. This means we cannot distinguish a known hosts entry that has a different type (`ssh-rsa`, `ssh-dsa`, etc.) from an entry with a matching type and a fingerprint mismatch: the former should be treated as an unknown host whereas the latter is a host key mismatch; they cannot be distinguished without this patch. - If the user connects on a non-default port (i.e. not 22), this is not passed to the callback in any way. Since there can be different known host entries for different ports and they should be treated as distinct, this also means the current API cannot be used to verify hosts serving SSH on non-standard ports. This patch passes the port. I will try to upstream some version of this patch to libgit2. The same patch has already been applied to the LibGit2 JLL. Fixes JuliaLang#38777. Might fix JuliaLang/Pkg.jl#2334.
…ang#39324) It seems that no one actually verifies SSH host identity with libgit2 because the callback doesn't give enough information do so correctly: - It doesn't give the actual host key fingerprint, but rather three different hashes thereof. This means we cannot distinguish a known hosts entry that has a different type (`ssh-rsa`, `ssh-dsa`, etc.) from an entry with a matching type and a fingerprint mismatch: the former should be treated as an unknown host whereas the latter is a host key mismatch; they cannot be distinguished without this patch. - If the user connects on a non-default port (i.e. not 22), this is not passed to the callback in any way. Since there can be different known host entries for different ports and they should be treated as distinct, this also means the current API cannot be used to verify hosts serving SSH on non-standard ports. This patch passes the port. I will try to upstream some version of this patch to libgit2. The same patch has already been applied to the LibGit2 JLL. Fixes JuliaLang#38777. Might fix JuliaLang/Pkg.jl#2334.
It seems that no one actually verifies SSH host identity with libgit2 because the callback doesn't give enough information do so correctly: - It doesn't give the actual host key fingerprint, but rather three different hashes thereof. This means we cannot distinguish a known hosts entry that has a different type (`ssh-rsa`, `ssh-dsa`, etc.) from an entry with a matching type and a fingerprint mismatch: the former should be treated as an unknown host whereas the latter is a host key mismatch; they cannot be distinguished without this patch. - If the user connects on a non-default port (i.e. not 22), this is not passed to the callback in any way. Since there can be different known host entries for different ports and they should be treated as distinct, this also means the current API cannot be used to verify hosts serving SSH on non-standard ports. This patch passes the port. I will try to upstream some version of this patch to libgit2. The same patch has already been applied to the LibGit2 JLL. Fixes #38777. Might fix JuliaLang/Pkg.jl#2334. (cherry picked from commit 2b13234)
Our git server is behind a load balancer, so the IP changes frequently. This is the git behaviour:
G1. On first clone, it says the authenticity of the host cannot be established, here's the fingerprint, do you want to trust it. If the user says yes, an entry is added to the
~/.ssh/known_hosts
file in the form<hostname>,<ip> <key type> <fingerprint>
.G2. On the first clone after the IP changes, git sees an entry for the same host name with the same fingerprint and a different IP, adds an entry to the
~/.ssh/known_hosts
file in the form<ip> <key type> <fingerprint>
, and warns the user that this took place. This only happens when the host name and fingerprint are identical.This is the Julia behaviour:
J1. On first clone, it shows "SSH host verification: the server
<hostname>
is not a known host. Please runssh-keyscan <hostname> >> ~/.ssh/known_hosts
in order to add the server to your known hosts file and then try again.".J2. If the user does that, then entries in the form of
<hostname> <key type> <fingerprint>
are added to the~/.ssh/known_hosts
file are added.J3. On the first clone after the IP changes, Julia succeeds
Mixing these can cause interesting behaviour.
J1, J2, G2 is fine, though notably git still adds those IP entries to the
~/.ssh/known_hosts
file.G1, J3 does not work. Instead Julia will fail and say "SSH host verification: the identity of the server
<hostname>
does not match its known hosts record.". This is the problem.I say Julia should either a) allow the connection or b) give the prompt to run
ssh-keyscan
, which will cause J3 to succeed.The text was updated successfully, but these errors were encountered: