[ https://issues.apache.org/jira/browse/SSHD-1291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17582903#comment-17582903 ]
Evgeny Pasynkov commented on SSHD-1291: --------------------------------------- The very basic test which demonstrates this behaviour (The difference from server ran in SSHD tests is using the AsyncAuthException, actually). Just run the program and connect to it from console: "ssh -vvv ssh://localhost:2220 abc" {code:java} package demo; import org.apache.sshd.common.NamedResource; import org.apache.sshd.common.config.keys.KeyUtils; import org.apache.sshd.common.digest.BuiltinDigests; import org.apache.sshd.common.keyprovider.KeyPairProvider; import org.apache.sshd.common.util.security.SecurityUtils; import org.apache.sshd.server.ServerBuilder; import org.apache.sshd.server.SshServer; import org.apache.sshd.server.auth.AsyncAuthException; import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator; import org.apache.sshd.server.session.ServerSession; import org.apache.sshd.server.shell.UnknownCommand; import java.io.ByteArrayInputStream; import java.security.KeyPair; import java.security.PublicKey; public class AsyncPublicKeyAuthServer { public static void main(String[] args) throws Exception { SshServer sshd = ServerBuilder.builder().build(); final KeyPair serverKey = SecurityUtils.loadKeyPairIdentities( null, NamedResource.ofName(""), new ByteArrayInputStream(PrivateKey.getBytes()), null).iterator().next(); sshd.setPort(2220); sshd.setKeyPairProvider(KeyPairProvider.wrap(serverKey)); sshd.setCommandFactory((channel, command) -> new UnknownCommand(command)); sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() { @Override public boolean authenticate(String username, PublicKey key, ServerSession session) throws AsyncAuthException { String fingerprint = KeyUtils.getFingerPrint(BuiltinDigests.md5, key); AsyncAuthException ex = new AsyncAuthException(); new Thread(new Runnable() { @Override public void run() { ex.setAuthed(true); } }).start(); throw ex; } }); sshd.start(); System.out.println("Server started on port " + sshd.getPort()); System.out.println("Press any key to exit"); System.in.read(); System.out.println("Finished"); sshd.stop(); } private static String PrivateKey = "-----BEGIN OPENSSH PRIVATE KEY-----\n" + "b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEb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JF3TjaLVUrWjH1xz9KXhyc4RXBqmnsqaNNNQott5deid4MD4MpkRsad1+iCjFT307k5+/J\n" + "5QRD3p81p5SZH9LGmyRJyv0A3a//nkjFaRybk2eCzXVMp6AXCZGOKFWZeYOI+zXlUDbGHF\n" + "NhxFCsXxco+CEv8CBiBDBDCaXcsjoVIwAAAMEA1L7X6TsSUzYCHG19HdNxaSX7vlyi2QAH\n" + "uKxR28fSjyndoOIendYJXFcDjZZzCYn+oJ88WSpBM40mF5dkY2J0Raf3ZC4EeQ9plqjAVA\n" + "k/n/yVtVt4V1Rm6U1mWgIX6gAbEj2FyGe6xM41C6yBEk1WF1V6LeggYtxfgaBFVyjkUllz\n" + "bl6eyF7UnReb1ztqLVQGBp8Szgb08Tgm9pPmmLlN/nAWDfvV33iluMfsB+rNYiQekN5U4J\n" + "8UjNRvpBespKfHAAAAJnBhc3lua292QEV2Z2VueXMtTUJQLmxhYnMuaW50ZWxsaWoubmV0\n" + "AQIDBA==\n" + "-----END OPENSSH PRIVATE KEY-----\n"; } {code} > Protocol violation when using async PublicKey auth > -------------------------------------------------- > > Key: SSHD-1291 > URL: https://issues.apache.org/jira/browse/SSHD-1291 > Project: MINA SSHD > Issue Type: Bug > Affects Versions: 2.9.0 > Reporter: Evgeny Pasynkov > Priority: Major > > Hi. > I've noticed that SSHD server violates RFC 4252 section 7 > (https://www.rfc-editor.org/rfc/rfc4252#section-7) when using asynchronous > public key auth (which means throwing AsyncAuthException() from > PublickeyAuthenticator implementation. > Part of the client log when using sync approach > {code} > debug1: Next authentication method: publickey > debug1: Offering public key:xxxxxxx RSA > SHA256:yCES5R3fRyROO6W3GRfte9EelwXcM29IM3zOzsvwuv0 > debug3: send packet: type 50 > debug2: we sent a publickey packet, wait for reply > debug3: receive packet: type 60 > debug1: Server accepts key: xxxxxxxx RSA > SHA256:yCES5R3fRyROO6W3GRfte9EelwXcM29IM3zOzsvwuv0 > debug3: sign_and_send_pubkey: using publickey with RSA > SHA256:yCES5R3fRyROO6W3GRfte9EelwXcM29IM3zOzsvwuv0 > debug3: sign_and_send_pubkey: signing using rsa-sha2-512 > SHA256:yCES5R3fRyROO6W3GRfte9EelwXcM29IM3zOzsvwuv0 > debug3: send packet: type 50 > debug3: receive packet: type 52 > Authenticated to localhost ([::1]:2224) using "publickey". > {code} > when using "async" approach: > {code} > debug1: Next authentication method: publickey > debug1: Offering public key: xxxxxxxxxx RSA > SHA256:yCES5R3fRyROO6W3GRfte9EelwXcM29IM3zOzsvwuv0 > debug3: send packet: type 50 > debug2: we sent a publickey packet, wait for reply > debug3: receive packet: type 52 > Authenticated to localhost ([::1]:2224) using "publickey". > {code} > Please note that mandatory packet SSH_MSG_USERAUTH_PK_OK is missing. > Though standard client tolerates this difference (at least OpenSSH_9.0p1), > not all of them do this. Jsch failed to establish session -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org For additional commands, e-mail: dev-h...@mina.apache.org