Skip to content

Host based Connect - error java.io.IOException after requesting password for the key #17

@VladimZaguzin

Description

@VladimZaguzin

trying to use j2ssh to make a SSH2 Host based Connect

and getting error

com.sshtools.ssh.SshException: java.io.IOException at com.sshtools.ssh2.Ssh2HostbasedAuthentication.authenticate(Ssh2HostbasedAuthentication.java:112) at com.sshtools.ssh2.AuthenticationProtocol.authenticate(AuthenticationProtocol.java:206) at com.sshtools.ssh2.Ssh2Client.authenticate(Ssh2Client.java:340) at shh_test.main(shh_test.java:110)

Caused by: java.io.IOException: Failed to sign data! Could not sign data at com.sshtools.ssh.components.jce.Ssh2RsaPrivateCrtKey.sign(Ssh2RsaPrivateCrtKey.java:134) at com.sshtools.ssh2.Ssh2HostbasedAuthentication.authenticate(Ssh2HostbasedAuthentication.java:99)

i basically copied the example code from SSH2HostbasedConnect.java with small modifications such as hard-coded user name and host name

error happened at step

            SshKeyPair pair;
            if (pkfile.isPassphraseProtected()) {
                System.out.print("Passphrase: ");
                pair = pkfile.toKeyPair(reader.readLine());
            } else
                pair = pkfile.toKeyPair(null);

            pk.setPrivateKey(pair.getPrivateKey());
            pk.setPublicKey(pair.getPublicKey());
        } while (ssh.authenticate(pk) != SshAuthentication.COMPLETE
                && ssh.isConnected());

I know for sure that my private key is working and I used it in tactia; and it had status - opened

what can cause it ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions