[
https://issues.apache.org/jira/browse/SSHD-1246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17493682#comment-17493682
]
g3g4x5x6 edited comment on SSHD-1246 at 2/17/22, 6:18 AM:
----------------------------------------------------------
{code:java}
KeyPair keyPair = PuttyKeyUtils.DEFAULT_INSTANCE.loadKeyPairs(null,
Path.of("C:\\Users\\G3G4X5X6\\Desktop\\UltimateShell\\ssh-key\\test2\\private.ppk"),
FilePasswordProvider.of("123456")
).iterator().next(); {code}
thanks, I tested private.ppk without password, it's ok.
But when i test with password, something wrong.
!image-2022-02-17-14-15-49-444.png!
java.io.StreamCorruptedException: Negative block length requested: -1167343353
at org.apache.sshd.putty.PuttyKeyReader.read(PuttyKeyReader.java:72)
at org.apache.sshd.putty.PuttyKeyReader.readInt(PuttyKeyReader.java:61)
at
org.apache.sshd.putty.RSAPuttyKeyDecoder.loadKeyPairs(RSAPuttyKeyDecoder.java:64)
at
org.apache.sshd.putty.AbstractPuttyKeyDecoder.loadKeyPairs(AbstractPuttyKeyDecoder.java:270)
at
org.apache.sshd.putty.AbstractPuttyKeyDecoder.loadKeyPairs(AbstractPuttyKeyDecoder.java:259)
at
org.apache.sshd.putty.AbstractPuttyKeyDecoder.loadKeyPairs(AbstractPuttyKeyDecoder.java:216)
at
org.apache.sshd.putty.AbstractPuttyKeyDecoder.loadKeyPairs(AbstractPuttyKeyDecoder.java:161)
at
org.apache.sshd.putty.AbstractPuttyKeyDecoder.loadKeyPairs(AbstractPuttyKeyDecoder.java:129)
at
org.apache.sshd.common.config.keys.loader.KeyPairResourceParser$2.loadKeyPairs(KeyPairResourceParser.java:166)
at
org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader.loadKeyPairs(KeyPairResourceLoader.java:157)
at
org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader.loadKeyPairs(KeyPairResourceLoader.java:148)
at
org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader.loadKeyPairs(KeyPairResourceLoader.java:139)
at
org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader.loadKeyPairs(KeyPairResourceLoader.java:115)
at
org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader.loadKeyPairs(KeyPairResourceLoader.java:90)
at
org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader.loadKeyPairs(KeyPairResourceLoader.java:84)
at
com.g3g4x5x6.ui.panels.ssh.SshTabbedPane.getSession(SshTabbedPane.java:111)
at com.g3g4x5x6.ui.panels.ssh.SshTabbedPane.init(SshTabbedPane.java:102)
at com.g3g4x5x6.ui.panels.ssh.SshTabbedPane.<init>(SshTabbedPane.java:59)
was (Author: g3g4x5x6):
{code:java}
KeyPair keyPair = PuttyKeyUtils.DEFAULT_INSTANCE.loadKeyPairs(null,
Path.of("C:\\Users\\G3G4X5X6\\Desktop\\UltimateShell\\ssh-key\\test2\\private.ppk"),
FilePasswordProvider.of("123456")
).iterator().next(); {code}
I tested private.ppk without password, it's ok.
But when i test with password, something wrong.
!image-2022-02-17-14-15-49-444.png!
java.io.StreamCorruptedException: Negative block length requested: -1167343353
at org.apache.sshd.putty.PuttyKeyReader.read(PuttyKeyReader.java:72)
at org.apache.sshd.putty.PuttyKeyReader.readInt(PuttyKeyReader.java:61)
at
org.apache.sshd.putty.RSAPuttyKeyDecoder.loadKeyPairs(RSAPuttyKeyDecoder.java:64)
at
org.apache.sshd.putty.AbstractPuttyKeyDecoder.loadKeyPairs(AbstractPuttyKeyDecoder.java:270)
at
org.apache.sshd.putty.AbstractPuttyKeyDecoder.loadKeyPairs(AbstractPuttyKeyDecoder.java:259)
at
org.apache.sshd.putty.AbstractPuttyKeyDecoder.loadKeyPairs(AbstractPuttyKeyDecoder.java:216)
at
org.apache.sshd.putty.AbstractPuttyKeyDecoder.loadKeyPairs(AbstractPuttyKeyDecoder.java:161)
at
org.apache.sshd.putty.AbstractPuttyKeyDecoder.loadKeyPairs(AbstractPuttyKeyDecoder.java:129)
at
org.apache.sshd.common.config.keys.loader.KeyPairResourceParser$2.loadKeyPairs(KeyPairResourceParser.java:166)
at
org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader.loadKeyPairs(KeyPairResourceLoader.java:157)
at
org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader.loadKeyPairs(KeyPairResourceLoader.java:148)
at
org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader.loadKeyPairs(KeyPairResourceLoader.java:139)
at
org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader.loadKeyPairs(KeyPairResourceLoader.java:115)
at
org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader.loadKeyPairs(KeyPairResourceLoader.java:90)
at
org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader.loadKeyPairs(KeyPairResourceLoader.java:84)
at
com.g3g4x5x6.ui.panels.ssh.SshTabbedPane.getSession(SshTabbedPane.java:111)
at com.g3g4x5x6.ui.panels.ssh.SshTabbedPane.init(SshTabbedPane.java:102)
at com.g3g4x5x6.ui.panels.ssh.SshTabbedPane.<init>(SshTabbedPane.java:59)
> Improve documentation on loading private/public keys from files
> ---------------------------------------------------------------
>
> Key: SSHD-1246
> URL: https://issues.apache.org/jira/browse/SSHD-1246
> Project: MINA SSHD
> Issue Type: Improvement
> Reporter: g3g4x5x6
> Assignee: Lyor Goldstein
> Priority: Minor
> Attachments: image-2022-02-17-14-15-49-444.png
>
>
> I want to add PublicKeyIdentity
> {code:java}
> private ClientSession getSession(SshClient client) {
> ClientSession session;
> try {
> session = client.connect(this.user, this.host,
> this.port).verify(5000, TimeUnit.MILLISECONDS).getSession();
> // session.addPasswordIdentity(this.pass);
>
> log.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>KeyPair>>>>>>>>>>>>>>>>>>>>>>>>>>>");
> RSAPuttyKeyDecoder rsaPuttyKeyDecoder = new RSAPuttyKeyDecoder();
> KeyPair keyPair = rsaPuttyKeyDecoder.loadKeyPairs(null,
> new PuttyKeyReader(new
> FileInputStream("C:\\Users\\G3G4X5X6\\Desktop\\UltimateShell\\ssh-key\\test1\\key.pub")),
> new PuttyKeyReader(new
> FileInputStream("C:\\Users\\G3G4X5X6\\Desktop\\UltimateShell\\ssh-key\\test1\\private.ppk")),
> null).iterator().next();
> session.addPublicKeyIdentity(keyPair);
> session.auth().verify(15, TimeUnit.SECONDS);
>
> session.setSessionHeartbeat(SessionHeartbeatController.HeartbeatType.IGNORE,
> Duration.ofMinutes(3));
> session.sendIgnoreMessage("".getBytes(StandardCharsets.UTF_8));
> return session;
> } catch (IOException | GeneralSecurityException e) {
> e.printStackTrace();
> DialogUtil.error(e.getMessage());
> return null;
> }
> } {code}
> {*}Error, but i don't know why, help!{*}{*}{*}
> {code:java}
> java.io.EOFException
> at java.base/java.io.DataInputStream.readInt(DataInputStream.java:397)
> at org.apache.sshd.putty.PuttyKeyReader.read(PuttyKeyReader.java:66)
> at org.apache.sshd.putty.PuttyKeyReader.readInt(PuttyKeyReader.java:61)
> at
> org.apache.sshd.putty.RSAPuttyKeyDecoder.loadKeyPairs(RSAPuttyKeyDecoder.java:60)
> at
> com.g3g4x5x6.ui.panels.ssh.SshTabbedPane.getSession(SshTabbedPane.java:123)
> ...... {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]