jgit - 使用 JGit 通过 InMemoryRepository 和 SSH 获取 git repo
问题描述
我在 web 服务中使用 JGit,需要从多个存储库中提取/获取。因此,我使用的InMemoryRepository
是 JGit。此外,我想使用 SSH(私有/公共 RSA 密钥对)访问存储库。
如https://bugs.eclipse.org/bugs/show_bug.cgi?id=549456中所述,这似乎是不可能的。我找到了另一篇文章,Thomas Wolf 描述了如何实现这一点。
不知何故,这对我不起作用。到目前为止,这是我的代码。
private void fetchGitRepository(String repositoryUri, java.security.KeyPair keyPair) {
DfsRepositoryDescription repoDesc = new DfsRepositoryDescription();
Repository repository = new InMemoryRepository(repoDesc);
repository.getObjectDatabase();
try (Git git = new Git(repository)) {
FetchCommand fetchCommand = git.fetch()
.setRemote(repositoryUri)
.setRefSpecs(new RefSpec("+refs/heads/*:refs/heads/*"));
if (keyPair != null) {
SshTransportConfigCallback transportConfigCallback = new SshTransportConfigCallback(keyPair);
fetchCommand.setTransportConfigCallback(transportConfigCallback);
}
fetchCommand.call();
}
}
class SshTransportConfigCallback implements TransportConfigCallback {
private KeyPair keyPair;
public SshTransportConfigCallback(KeyPair keyPair) {
this.keyPair = keyPair;
}
@Override
public void configure(Transport transport) {
if (transport instanceof SshTransport) {
SshTransport sshTransport = (SshTransport) transport;
sshTransport.setSshSessionFactory(new MySessionFactory(keyPair));
}
}
private static class MySessionFactory extends SshdSessionFactory {
private final KeyPair keyPair;
public MySessionFactory(KeyPair keyPair) {
this.keyPair = keyPair;
}
@Override
public File getHomeDirectory() {
return null;
}
@Override
public File getSshDirectory() {
return null;
}
@Override
protected File getSshConfig(File sshDir) {
return null;
}
@Override
protected ServerKeyDatabase getServerKeyDatabase(File homeDir, File sshDir) {
return new ServerKeyDatabase() {
@Override
public List<PublicKey> lookup(String connectAddress, InetSocketAddress remoteAddress, Configuration config) {
return emptyList();
}
@Override
public boolean accept(String connectAddress, InetSocketAddress remoteAddress, PublicKey serverKey, Configuration config, CredentialsProvider provider) {
return true; // TODO: Fix this later
}
};
}
@Override
protected List<Path> getDefaultKnownHostsFiles(File sshDir) {
return emptyList();
}
@Override
protected Iterable<KeyPair> getDefaultKeys(File sshDir) {
return of(keyPair);
}
@Override
protected List<Path> getDefaultIdentities(File sshDir) {
return emptyList();
}
@Override
protected String getDefaultPreferredAuthentications() {
return "publickey";
}
}
}
我收到以下异常:
2021-10-23 18:04:49.773 DEBUG 25750 --- [nio-9000-exec-5] o.a.sshd.common.io.nio2.Nio2Connector : Connecting to github.com/140.82.121.3:22
2021-10-23 18:04:49.774 DEBUG 25750 --- [nio-9000-exec-5] o.a.sshd.common.io.nio2.Nio2Connector : setOption(SO_REUSEADDR)[true] from property=Property[socket-reuseaddr](Boolean]
2021-10-23 18:04:49.801 DEBUG 25750 --- []-nio2-thread-1] o.a.sshd.common.io.nio2.Nio2Session : Creating IoSession on /192.168.178.37:52145 from github.com/140.82.121.3:22 via null
2021-10-23 18:04:49.801 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : Client session created: Nio2Session[local=/192.168.178.37:52145, remote=github.com/140.82.121.3:22]
2021-10-23 18:04:49.801 DEBUG 25750 --- []-nio2-thread-1] o.a.s.c.session.ClientUserAuthService : ClientUserAuthService(JGitClientSession[null@github.com/140.82.121.3:22]) use configured preferences: publickey
2021-10-23 18:04:49.801 DEBUG 25750 --- []-nio2-thread-1] o.a.s.c.session.ClientUserAuthService : ClientUserAuthService(JGitClientSession[null@github.com/140.82.121.3:22]) client methods: [publickey]
2021-10-23 18:04:49.802 DEBUG 25750 --- []-nio2-thread-1] o.a.s.c.s.h.SessionTimeoutListener : sessionCreated(JGitClientSession[null@github.com/140.82.121.3:22]) tracking
2021-10-23 18:04:49.802 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : initializeProxyConnector(JGitClientSession[null@github.com/140.82.121.3:22]) no proxy to initialize
2021-10-23 18:04:49.802 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : sendIdentification(JGitClientSession[null@github.com/140.82.121.3:22]): SSH-2.0-APACHE-SSHD-2.7.0
2021-10-23 18:04:49.802 DEBUG 25750 --- []-nio2-thread-1] o.a.sshd.common.io.nio2.Nio2Session : writeBuffer(Nio2Session[local=/192.168.178.37:52145, remote=github.com/140.82.121.3:22]) writing 27 bytes
2021-10-23 18:04:50.375 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : HostKeyAlgorithms [ecdsa-sha2-nistp256-cert-v01@openssh.com, ecdsa-sha2-nistp384-cert-v01@openssh.com, ecdsa-sha2-nistp521-cert-v01@openssh.com, ssh-ed25519-cert-v01@openssh.com, rsa-sha2-512-cert-v01@openssh.com, rsa-sha2-256-cert-v01@openssh.com, ssh-rsa-cert-v01@openssh.com, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-ed25519, sk-ecdsa-sha2-nistp256@openssh.com, sk-ssh-ed25519@openssh.com, rsa-sha2-512, rsa-sha2-256, ssh-rsa, ssh-dss-cert-v01@openssh.com, ssh-dss]
2021-10-23 18:04:50.375 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : KexAlgorithms ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256,diffie-hellman-group18-sha512,diffie-hellman-group17-sha512,diffie-hellman-group16-sha512,diffie-hellman-group15-sha512,diffie-hellman-group14-sha256,ext-info-c
2021-10-23 18:04:50.375 DEBUG 25750 --- []-nio2-thread-1] s.c.k.e.DefaultClientKexExtensionHandler : handleKexInitProposal(JGitClientSession[null@github.com/140.82.121.3:22]): proposing HostKeyAlgorithms [ecdsa-sha2-nistp256-cert-v01@openssh.com, ecdsa-sha2-nistp384-cert-v01@openssh.com, ecdsa-sha2-nistp521-cert-v01@openssh.com, ssh-ed25519-cert-v01@openssh.com, rsa-sha2-512-cert-v01@openssh.com, rsa-sha2-256-cert-v01@openssh.com, ssh-rsa-cert-v01@openssh.com, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-ed25519, sk-ecdsa-sha2-nistp256@openssh.com, sk-ssh-ed25519@openssh.com, rsa-sha2-512, rsa-sha2-256, ssh-rsa, ssh-dss-cert-v01@openssh.com, ssh-dss, ext-info-c]
2021-10-23 18:04:50.375 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : sendKexInit(JGitClientSession[null@github.com/140.82.121.3:22]) Send SSH_MSG_KEXINIT
2021-10-23 18:04:50.375 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : encode(JGitClientSession[null@github.com/140.82.121.3:22]) packet #0 sending command=20[SSH_MSG_KEXINIT] len=1304
2021-10-23 18:04:50.375 DEBUG 25750 --- []-nio2-thread-1] o.a.sshd.common.io.nio2.Nio2Session : writeBuffer(Nio2Session[local=/192.168.178.37:52145, remote=github.com/140.82.121.3:22]) writing 1320 bytes
2021-10-23 18:04:50.375 DEBUG 25750 --- [nio-9000-exec-5] o.a.s.c.future.DefaultConnectFuture : Connected to github.com/140.82.121.3:22 after 601766936 nanos
2021-10-23 18:04:50.375 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : doReadIdentification(JGitClientSession[git@github.com/140.82.121.3:22]) line: SSH-2.0-babeld-abb5d94f
2021-10-23 18:04:50.375 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : readIdentification(JGitClientSession[git@github.com/140.82.121.3:22]) Server version string: SSH-2.0-babeld-abb5d94f
2021-10-23 18:04:50.375 DEBUG 25750 --- [nio-9000-exec-5] o.a.s.c.session.ClientUserAuthService : auth(JGitClientSession[git@github.com/140.82.121.3:22])[ssh-connection] send SSH_MSG_USERAUTH_REQUEST for 'none'
2021-10-23 18:04:50.376 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : handleKexInit(JGitClientSession[git@github.com/140.82.121.3:22]) SSH_MSG_KEXINIT
2021-10-23 18:04:50.376 DEBUG 25750 --- [nio-9000-exec-5] o.e.j.i.t.sshd.JGitClientSession : enqueuePendingPacket(JGitClientSession[git@github.com/140.82.121.3:22])[SSH_MSG_USERAUTH_REQUEST] Start flagging packets as pending until key exchange is done
2021-10-23 18:04:50.376 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : setNegotiationResult(JGitClientSession[git@github.com/140.82.121.3:22]) Kex: server->client aes128-ctr hmac-sha2-256-etm@openssh.com none
2021-10-23 18:04:50.376 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : setNegotiationResult(JGitClientSession[git@github.com/140.82.121.3:22]) Kex: client->server aes128-ctr hmac-sha2-256-etm@openssh.com none
2021-10-23 18:04:50.376 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : setNegotiationResult(JGitClientSession[git@github.com/140.82.121.3:22]) Kex: kex algorithms = ecdh-sha2-nistp521
2021-10-23 18:04:50.376 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : setNegotiationResult(JGitClientSession[git@github.com/140.82.121.3:22]) Kex: server host key algorithms = rsa-sha2-512
2021-10-23 18:04:50.376 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : setNegotiationResult(JGitClientSession[git@github.com/140.82.121.3:22]) Kex: encryption algorithms (client to server) = aes128-ctr
2021-10-23 18:04:50.376 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : setNegotiationResult(JGitClientSession[git@github.com/140.82.121.3:22]) Kex: encryption algorithms (server to client) = aes128-ctr
2021-10-23 18:04:50.376 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : setNegotiationResult(JGitClientSession[git@github.com/140.82.121.3:22]) Kex: mac algorithms (client to server) = hmac-sha2-256-etm@openssh.com
2021-10-23 18:04:50.376 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : setNegotiationResult(JGitClientSession[git@github.com/140.82.121.3:22]) Kex: mac algorithms (server to client) = hmac-sha2-256-etm@openssh.com
2021-10-23 18:04:50.376 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : setNegotiationResult(JGitClientSession[git@github.com/140.82.121.3:22]) Kex: compression algorithms (client to server) = none
2021-10-23 18:04:50.376 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : setNegotiationResult(JGitClientSession[git@github.com/140.82.121.3:22]) Kex: compression algorithms (server to client) = none
2021-10-23 18:04:50.380 DEBUG 25750 --- []-nio2-thread-1] org.apache.sshd.client.kex.DHGClient : init(DHGClient[ecdh-sha2-nistp521])[JGitClientSession[git@github.com/140.82.121.3:22]] Send SSH_MSG_KEXDH_INIT
2021-10-23 18:04:50.380 DEBUG 25750 --- []-nio2-thread-1] o.e.j.i.t.sshd.JGitClientSession : encode(JGitClientSession[git@github.com/140.82.121.3:22]) packet #1 sending command=30[30] len=138
2021-10-23 18:04:50.380 DEBUG 25750 --- []-nio2-thread-1] o.a.sshd.common.io.nio2.Nio2Session : writeBuffer(Nio2Session[local=/192.168.178.37:52145, remote=github.com/140.82.121.3:22]) writing 152 bytes
2021-10-23 18:04:50.495 DEBUG 25750 --- []-nio2-thread-2] org.apache.sshd.client.kex.DHGClient : next(DHGClient[ecdh-sha2-nistp521])[JGitClientSession[git@github.com/140.82.121.3:22]] process command=SSH_MSG_KEXDH_REPLY
2021-10-23 18:04:50.503 DEBUG 25750 --- []-nio2-thread-2] o.e.j.i.t.sshd.JGitClientSession : setServerKey(JGitClientSession[git@github.com/140.82.121.3:22]) keyType=ssh-rsa, digest=SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
2021-10-23 18:04:50.503 DEBUG 25750 --- []-nio2-thread-2] o.e.j.i.t.sshd.JGitClientSession : handleKexMessage(JGitClientSession[git@github.com/140.82.121.3:22])[ecdh-sha2-nistp521] KEX processing complete after cmd=31
2021-10-23 18:04:50.995 DEBUG 25750 --- []-nio2-thread-2] o.e.j.i.t.sshd.JGitClientSession : checkKeys(JGitClientSession[git@github.com/140.82.121.3:22]) key=ssh-rsa-SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8, verified=true
2021-10-23 18:04:50.996 DEBUG 25750 --- []-nio2-thread-2] o.e.j.i.t.sshd.JGitClientSession : sendNewKeys(JGitClientSession[git@github.com/140.82.121.3:22]) Send SSH_MSG_NEWKEYS
2021-10-23 18:04:50.996 DEBUG 25750 --- []-nio2-thread-2] o.e.j.i.t.sshd.JGitClientSession : encode(JGitClientSession[git@github.com/140.82.121.3:22]) packet #2 sending command=21[SSH_MSG_NEWKEYS] len=1
2021-10-23 18:04:50.996 DEBUG 25750 --- []-nio2-thread-2] o.a.sshd.common.io.nio2.Nio2Session : writeBuffer(Nio2Session[local=/192.168.178.37:52145, remote=github.com/140.82.121.3:22]) writing 16 bytes
2021-10-23 18:04:50.996 DEBUG 25750 --- []-nio2-thread-2] o.e.j.i.t.sshd.JGitClientSession : handleNewKeys(JGitClientSession[git@github.com/140.82.121.3:22]) SSH_MSG_NEWKEYS command=SSH_MSG_NEWKEYS
2021-10-23 18:04:50.996 DEBUG 25750 --- []-nio2-thread-2] o.e.j.i.t.sshd.JGitClientSession : receiveNewKeys(JGitClientSession[git@github.com/140.82.121.3:22]) session ID=37:31:1f:99:1c:de:35:10:3c:e7:31:be:39:5b:ca:b0:5b:c0:e6:89:92:9c:6e:c2:cf:77:e9:a6:12:a7:3b:aa:ca:12:61:1e:43:b1:a4:d3:7e:30:a9:98:43:c4:76:b3:fd:f9:2c:a7:1d:e9:de:1c:c5:b4:90:ca:0e:c5:78:94
2021-10-23 18:04:50.997 DEBUG 25750 --- []-nio2-thread-2] o.e.j.i.t.sshd.JGitClientSession : receiveNewKeys(JGitClientSession[git@github.com/140.82.121.3:22]) inCipher=BaseCipher[AES, ivSize=16, kdfSize=16,AES/CTR/NoPadding, blkSize=16], outCipher=BaseCipher[AES, ivSize=16, kdfSize=16,AES/CTR/NoPadding, blkSize=16], recommended blocks limit=4294967296, actual=4294967296
2021-10-23 18:04:50.997 DEBUG 25750 --- []-nio2-thread-2] o.e.j.i.t.sshd.JGitClientSession : sendInitialServiceRequest(JGitClientSession[git@github.com/140.82.121.3:22]) Send SSH_MSG_SERVICE_REQUEST for ssh-userauth
2021-10-23 18:04:50.997 DEBUG 25750 --- []-nio2-thread-2] o.e.j.i.t.sshd.JGitClientSession : encode(JGitClientSession[git@github.com/140.82.121.3:22]) packet #3 sending command=5[SSH_MSG_SERVICE_REQUEST] len=17
2021-10-23 18:04:50.997 DEBUG 25750 --- []-nio2-thread-2] o.a.sshd.common.io.nio2.Nio2Session : writeBuffer(Nio2Session[local=/192.168.178.37:52145, remote=github.com/140.82.121.3:22]) writing 84 bytes
2021-10-23 18:04:50.997 DEBUG 25750 --- []-nio2-thread-2] o.e.j.i.t.sshd.JGitClientSession : encode(JGitClientSession[git@github.com/140.82.121.3:22]) packet #4 sending command=50[SSH_MSG_USERAUTH_REQUEST] len=34
2021-10-23 18:04:50.997 DEBUG 25750 --- []-nio2-thread-2] o.a.sshd.common.io.nio2.Nio2Session : writeBuffer(Nio2Session[local=/192.168.178.37:52145, remote=github.com/140.82.121.3:22]) writing 100 bytes
2021-10-23 18:04:50.997 DEBUG 25750 --- []-nio2-thread-2] o.e.j.i.t.sshd.JGitClientSession : handleNewKeys(JGitClientSession[git@github.com/140.82.121.3:22]) sent 1 pending packets
2021-10-23 18:04:51.099 DEBUG 25750 --- []-nio2-thread-3] s.c.k.e.DefaultClientKexExtensionHandler : handleServerSignatureAlgorithms(JGitClientSession[git@github.com/140.82.121.3:22]): [ssh-ed25519-cert-v01@openssh.com, ecdsa-sha2-nistp521-cert-v01@openssh.com, ecdsa-sha2-nistp384-cert-v01@openssh.com, ecdsa-sha2-nistp256-cert-v01@openssh.com, sk-ssh-ed25519-cert-v01@openssh.com, sk-ecdsa-sha2-nistp256-cert-v01@openssh.com, rsa-sha2-512-cert-v01@openssh.com, rsa-sha2-256-cert-v01@openssh.com, ssh-rsa-cert-v01@openssh.com, ssh-dss-cert-v01@openssh.com, sk-ssh-ed25519@openssh.com, sk-ecdsa-sha2-nistp256@openssh.com, ssh-ed25519, ecdsa-sha2-nistp521, ecdsa-sha2-nistp384, ecdsa-sha2-nistp256, rsa-sha2-512, rsa-sha2-256, ssh-rsa, ssh-dss]
2021-10-23 18:04:51.099 DEBUG 25750 --- []-nio2-thread-3] s.c.k.e.DefaultClientKexExtensionHandler : handleServerSignatureAlgorithms(JGitClientSession[git@github.com/140.82.121.3:22]): PubkeyAcceptedAlgorithms before: [ecdsa-sha2-nistp256-cert-v01@openssh.com, ecdsa-sha2-nistp384-cert-v01@openssh.com, ecdsa-sha2-nistp521-cert-v01@openssh.com, ssh-ed25519-cert-v01@openssh.com, rsa-sha2-512-cert-v01@openssh.com, rsa-sha2-256-cert-v01@openssh.com, ssh-rsa-cert-v01@openssh.com, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-ed25519, sk-ecdsa-sha2-nistp256@openssh.com, sk-ssh-ed25519@openssh.com, rsa-sha2-512, rsa-sha2-256, ssh-rsa, ssh-dss-cert-v01@openssh.com, ssh-dss]
2021-10-23 18:04:51.099 DEBUG 25750 --- []-nio2-thread-3] s.c.k.e.DefaultClientKexExtensionHandler : handleServerSignatureAlgorithms(JGitClientSession[git@github.com/140.82.121.3:22]): PubkeyAcceptedAlgorithms after: [ecdsa-sha2-nistp256-cert-v01@openssh.com, ecdsa-sha2-nistp384-cert-v01@openssh.com, ecdsa-sha2-nistp521-cert-v01@openssh.com, ssh-ed25519-cert-v01@openssh.com, rsa-sha2-512-cert-v01@openssh.com, rsa-sha2-256-cert-v01@openssh.com, ssh-rsa-cert-v01@openssh.com, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-ed25519, sk-ecdsa-sha2-nistp256@openssh.com, sk-ssh-ed25519@openssh.com, rsa-sha2-512, rsa-sha2-256, ssh-rsa, ssh-dss-cert-v01@openssh.com, ssh-dss]
2021-10-23 18:04:51.118 DEBUG 25750 --- []-nio2-thread-4] o.e.j.i.t.sshd.JGitClientSession : handleServiceAccept(JGitClientSession[git@github.com/140.82.121.3:22]) SSH_MSG_SERVICE_ACCEPT service=ssh-userauth
2021-10-23 18:04:51.157 DEBUG 25750 --- []-nio2-thread-5] o.a.s.c.session.ClientUserAuthService : processUserAuth(JGitClientSession[git@github.com/140.82.121.3:22]) Received SSH_MSG_USERAUTH_FAILURE - partial=false, methods=publickey
2021-10-23 18:04:51.157 DEBUG 25750 --- []-nio2-thread-5] o.a.s.c.session.ClientUserAuthService : tryNext(JGitClientSession[git@github.com/140.82.121.3:22]) starting authentication mechanisms: client=[publickey], server=[publickey]
2021-10-23 18:04:51.157 DEBUG 25750 --- []-nio2-thread-5] o.a.s.c.session.ClientUserAuthService : tryNext(JGitClientSession[git@github.com/140.82.121.3:22]) attempting method=publickey
2021-10-23 18:04:51.158 DEBUG 25750 --- []-nio2-thread-5] o.e.j.i.t.s.JGitPublicKeyAuthentication : sendAuthDataRequest(JGitClientSession[git@github.com/140.82.121.3:22])[ssh-connection] send SSH_MSG_USERAUTH_REQUEST request publickey type=rsa-sha2-512 - fingerprint=SHA256:wtyx9w1r6/ELRZtxJAwXjHmnIyeeQenDhh94q4HJgxE
2021-10-23 18:04:51.158 DEBUG 25750 --- []-nio2-thread-5] o.e.j.i.t.sshd.JGitClientSession : encode(JGitClientSession[git@github.com/140.82.121.3:22]) packet #5 sending command=50[SSH_MSG_USERAUTH_REQUEST] len=211
2021-10-23 18:04:51.158 DEBUG 25750 --- []-nio2-thread-5] o.a.sshd.common.io.nio2.Nio2Session : writeBuffer(Nio2Session[local=/192.168.178.37:52145, remote=github.com/140.82.121.3:22]) writing 276 bytes
2021-10-23 18:04:51.158 DEBUG 25750 --- []-nio2-thread-5] o.a.s.c.session.ClientUserAuthService : tryNext(JGitClientSession[git@github.com/140.82.121.3:22]) successfully processed initial buffer by method=publickey
2021-10-23 18:04:51.282 DEBUG 25750 --- []-nio2-thread-6] o.a.s.c.session.ClientUserAuthService : processUserAuth(JGitClientSession[git@github.com/140.82.121.3:22]) Received SSH_MSG_USERAUTH_FAILURE - partial=false, methods=publickey
2021-10-23 18:04:51.282 DEBUG 25750 --- []-nio2-thread-6] o.e.j.i.t.s.JGitPublicKeyAuthentication : sendAuthDataRequest(JGitClientSession[git@github.com/140.82.121.3:22])[ssh-connection] server rejected publickey authentication with known signature algorithm rsa-sha2-512
2021-10-23 18:04:51.282 DEBUG 25750 --- []-nio2-thread-6] o.e.j.i.t.s.JGitPublicKeyAuthentication : resolveAttemptedPublicKeyIdentity(JGitClientSession[git@github.com/140.82.121.3:22])[ssh-connection] no more keys to send
2021-10-23 18:04:51.282 DEBUG 25750 --- []-nio2-thread-6] o.a.s.c.session.ClientUserAuthService : tryNext(JGitClientSession[git@github.com/140.82.121.3:22]) no initial request sent by method=publickey
2021-10-23 18:04:51.282 DEBUG 25750 --- []-nio2-thread-6] o.e.j.i.t.s.JGitPublicKeyAuthentication : destroy(JGitClientSession[git@github.com/140.82.121.3:22])[ssh-connection]
2021-10-23 18:04:51.282 DEBUG 25750 --- []-nio2-thread-6] o.a.s.c.session.ClientUserAuthService : tryNext(JGitClientSession[git@github.com/140.82.121.3:22]) exhausted all methods - client=[publickey], server=[publickey]
2021-10-23 18:04:52.465 DEBUG 25750 --- [nio-9000-exec-5] o.e.j.i.t.sshd.JGitClientSession : close(JGitClientSession[git@github.com/140.82.121.3:22]) Closing immediately
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.e.j.i.t.sshd.JGitClientSession : signalAuthFailure(JGitClientSession[git@github.com/140.82.121.3:22]) type=SshException, signalled=false, first=false: Session is being closed
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.a.s.c.s.h.SessionTimeoutListener : sessionClosed(JGitClientSession[git@github.com/140.82.121.3:22]) un-tracked
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.a.s.c.session.ClientUserAuthService : close(org.apache.sshd.client.session.ClientUserAuthService@cd3cad2) Closing immediately
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.a.s.c.session.ClientUserAuthService : close(org.apache.sshd.client.session.ClientUserAuthService@cd3cad2)[Immediately] closed
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.a.s.c.session.ClientConnectionService : close(ClientConnectionService[JGitClientSession[git@github.com/140.82.121.3:22]]) Closing immediately
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.a.s.c.session.ClientConnectionService : stopHeartBeat(JGitClientSession[git@github.com/140.82.121.3:22]) no heartbeat to stop
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.a.s.c.session.ClientConnectionService : close(ClientConnectionService[JGitClientSession[git@github.com/140.82.121.3:22]])[Immediately] closed
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.a.sshd.common.io.nio2.Nio2Session : close(Nio2Session[local=/192.168.178.37:52145, remote=github.com/140.82.121.3:22]) Closing immediately
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.a.sshd.common.io.nio2.Nio2Session : doCloseImmediately(Nio2Session[local=/192.168.178.37:52145, remote=github.com/140.82.121.3:22]) closing socket=sun.nio.ch.UnixAsynchronousSocketChannelImpl[connected local=/192.168.178.37:52145 remote=github.com/140.82.121.3:22]
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.a.sshd.common.io.nio2.Nio2Session : doCloseImmediately(Nio2Session[local=/192.168.178.37:52145, remote=github.com/140.82.121.3:22]) socket=sun.nio.ch.UnixAsynchronousSocketChannelImpl[closed] closed
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.a.sshd.common.io.nio2.Nio2Connector : unmapSession(id=104): Nio2Session[local=/192.168.178.37:52145, remote=github.com/140.82.121.3:22]
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.e.j.i.t.sshd.JGitClientSession : close(JGitClientSession[git@github.com/140.82.121.3:22])[Immediately] state already Immediate
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.a.sshd.common.io.nio2.Nio2Session : close(Nio2Session[local=/192.168.178.37:52145, remote=github.com/140.82.121.3:22])[Immediately] closed
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.a.s.c.u.closeable.SequentialCloseable : doClose(org.apache.sshd.common.util.closeable.SequentialCloseable$1@5b272ea5) signal close complete immediately=true
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.e.j.i.t.sshd.JGitClientSession : close(JGitClientSession[git@github.com/140.82.121.3:22])[Immediately] closed
2021-10-23 18:04:52.466 DEBUG 25750 --- []-nio2-thread-7] o.a.sshd.common.io.nio2.Nio2Session : handleReadCycleFailure(Nio2Session[local=/192.168.178.37:52145, remote=github.com/140.82.121.3:22]) AsynchronousCloseException after 1183659791 nanos at read cycle=7: null
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.e.j.i.transport.sshd.JGitSshClient : close(JGitSshClient[97d9893]) Closing immediately
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.a.sshd.common.io.nio2.Nio2Connector : close(org.apache.sshd.common.io.nio2.Nio2Connector@7cd2a6a6) Closing immediately
2021-10-23 18:04:52.466 DEBUG 25750 --- [nio-9000-exec-5] o.a.sshd.common.io.nio2.Nio2Connector : close(org.apache.sshd.common.io.nio2.Nio2Connector@7cd2a6a6)[Immediately] closed
2021-10-23 18:04:52.467 DEBUG 25750 --- [nio-9000-exec-5] o.a.s.c.u.closeable.SequentialCloseable : doClose(org.apache.sshd.common.util.closeable.SequentialCloseable$1@7cced81d) signal close complete immediately=true
2021-10-23 18:04:52.467 DEBUG 25750 --- [nio-9000-exec-5] o.e.j.i.transport.sshd.JGitSshClient : close(JGitSshClient[97d9893])[Immediately] closed
2021-10-23 18:04:52.468 DEBUG 25750 --- [nio-9000-exec-5] o.s.web.servlet.DispatcherServlet : Failed to complete request: com.mlaide.webserver.service.git.GitDiffException: org.eclipse.jgit.api.errors.TransportException: git@github.com:MLAide/python-client.git: Cannot log in at github.com:22
2021-10-23 18:04:52.469 ERROR 25750 --- [nio-9000-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.mlaide.webserver.service.git.GitDiffException: org.eclipse.jgit.api.errors.TransportException: git@github.com:MLAide/python-client.git: Cannot log in at github.com:22] with root cause
org.apache.sshd.common.SshException: No more authentication methods available
at org.apache.sshd.client.session.ClientUserAuthService.tryNext(ClientUserAuthService.java:353) ~[sshd-osgi-2.7.0.jar:2.7.0]
at org.apache.sshd.client.session.ClientUserAuthService.processUserAuth(ClientUserAuthService.java:288) ~[sshd-osgi-2.7.0.jar:2.7.0]
at org.apache.sshd.client.session.ClientUserAuthService.process(ClientUserAuthService.java:225) ~[sshd-osgi-2.7.0.jar:2.7.0]
at org.apache.sshd.common.session.helpers.AbstractSession.doHandleMessage(AbstractSession.java:503) ~[sshd-osgi-2.7.0.jar:2.7.0]
at org.apache.sshd.common.session.helpers.AbstractSession.handleMessage(AbstractSession.java:429) ~[sshd-osgi-2.7.0.jar:2.7.0]
at org.apache.sshd.common.session.helpers.AbstractSession.decode(AbstractSession.java:1466) ~[sshd-osgi-2.7.0.jar:2.7.0]
at org.apache.sshd.common.session.helpers.AbstractSession.messageReceived(AbstractSession.java:389) ~[sshd-osgi-2.7.0.jar:2.7.0]
at org.eclipse.jgit.internal.transport.sshd.JGitClientSession.messageReceived(JGitClientSession.java:198) ~[org.eclipse.jgit.ssh.apache-5.13.0.202109080827-r.jar:5.13.0.202109080827-r]
at org.apache.sshd.common.session.helpers.AbstractSessionIoHandler.messageReceived(AbstractSessionIoHandler.java:64) ~[sshd-osgi-2.7.0.jar:2.7.0]
at org.apache.sshd.common.io.nio2.Nio2Session.handleReadCycleCompletion(Nio2Session.java:359) ~[sshd-osgi-2.7.0.jar:2.7.0]
at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:336) ~[sshd-osgi-2.7.0.jar:2.7.0]
at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:333) ~[sshd-osgi-2.7.0.jar:2.7.0]
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.lambda$completed$0(Nio2CompletionHandler.java:38) ~[sshd-osgi-2.7.0.jar:2.7.0]
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318) ~[na:na]
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.completed(Nio2CompletionHandler.java:37) ~[sshd-osgi-2.7.0.jar:2.7.0]
at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:129) ~[na:na]
at java.base/sun.nio.ch.Invoker$2.run(Invoker.java:221) ~[na:na]
at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
我使用了以下库版本:
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>5.13.0.202109080827-r</version>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit.ssh.apache</artifactId>
<version>5.13.0.202109080827-r</version>
</dependency>
解决方案
推荐阅读
- ios - Kotlin 多平台框架文件太大
- c++ - 尝试使用 VS2019 构建原始 VS2013 C++ 项目时 xtr1common 和 type_traits 中的错误
- azure - 寻找最合适的 Azure 解决方案
- dataweave - 在 Anypoint Studio 中更新元数据
- intellij-idea - intellij 终端环境变量设置为全局
- spring-boot - Docker 撰写未在 Springboot application.yml 中使用的环境变量
- android - 在 VScode 和 android studio 中在 Flutter 中编译我的应用程序时出错
- go - 将带有用破折号分隔的单词的标志映射到 camel_case 配置?
- javascript - 从 page.$$('input') 中的 ElementHandle 获取输入类型
- python - 霍夫圆变换python