I am trying to authentic using a public key but I get the error: Private key is not in the default format
Can someone please help me change the format of my private key file.
HERE IS MY CODE:
Expand|Select|Wrap|Line Numbers
- //Authenticate using a public key
- PublicKeyAuthenticationClient pk = new PublicKeyAuthenticationClient();
- pk.setUsername(user);
- System.out.println("I got past the authenticate the public key");
- // open up the private key file
- SshPrivateKey key = null;
- File hostsFile = new File("$HOME/.ssh/known_hosts");
- SshPrivateKeyFile file = SshPrivateKeyFile.parse(hostsFile);
- key = file.toPrivateKey(password);
- pk.setKey(key);
- int result = ssh.authenticate(pk);
ISCONNECTED: true
I got past the authenticate the public key
Sep 21, 2010 12:31:43 PM com.sshtools.j2ssh.transport.publickey.SshPrivateK eyFile parse
INFO: Parsing private key file
Sep 21, 2010 12:31:43 PM com.sshtools.j2ssh.transport.publickey.SshPrivateK eyFile parse
INFO: Private key is not in the default format, attempting parse with other supported formats
YOU FAILED IN THE CONNECT
Error: com.sshtools.j2ssh.transport.publickey.InvalidSshK eyException: The key format is not a supported format
THANKS A LOT FOR THE HELP!!