-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NullPointerException using OpenSSH RSA public key #484
Comments
Is your private key protected by a passphrase? SSHJ tries to decrypt the key. If it is not, I'd like to know the exact command to generate such a key. I agree that an NPE is bad, but before deciding on the solution I'd need to know the above. |
Hi Jeroen,
Thanks for the quick answer. I created my public keys using ssh-keygen and
providing a password:
sh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/josu/.ssh/id_rsa):
/Users/josu/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
My goal with the ticket is to inform that the case of a password protected
key pair does not seem to be covered by the API.
By the way, I have created a key without password and the
NullPointerException is gone, but I have another issue (I have to
investigate a bit more):
14:44:19.371 [main] DEBUG net.schmizz.sshj.userauth.method.AuthPublickey -
Attempting authentication using
com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile@3dd818e8
14:44:19.383 [main] DEBUG
com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile - Reading
unencrypted keypair
14:44:19.383 [main] INFO
com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile - Read key
type: ssh-rsa
net.schmizz.sshj.userauth.UserAuthException: Exhausted available
authentication methods
at net.schmizz.sshj.SSHClient.auth(SSHClient.java:231)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:346)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:395)
at net.schmizz.sshj.SSHClient.authPublickey(SSHClient.java:325)
at BugWithOpenSshKey.main(BugWithOpenSshKey.java:17)
Caused by: net.schmizz.sshj.userauth.UserAuthException: Problem getting
public key from
com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile@3dd818e8
at
net.schmizz.sshj.userauth.method.KeyedAuthMethod.putPubKey(KeyedAuthMethod.java:46)
at
net.schmizz.sshj.userauth.method.AuthPublickey.buildReq(AuthPublickey.java:62)
at
net.schmizz.sshj.userauth.method.AuthPublickey.buildReq(AuthPublickey.java:81)
at
net.schmizz.sshj.userauth.method.AbstractAuthMethod.request(AbstractAuthMethod.java:68)
at net.schmizz.sshj.userauth.UserAuthImpl.authenticate(UserAuthImpl.java:72)
at net.schmizz.sshj.SSHClient.auth(SSHClient.java:225)
... 4 more
Caused by: net.schmizz.sshj.common.Buffer$BufferException: Bad item length:
43423772
at net.schmizz.sshj.common.Buffer.readString(Buffer.java:397)
at net.schmizz.sshj.common.Buffer.readString(Buffer.java:412)
at
com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile.readUnencrypted(OpenSSHKeyV1KeyFile.java:190)
at
com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile.readDecodedKeyPair(OpenSSHKeyV1KeyFile.java:107)
at
com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile.readKeyPair(OpenSSHKeyV1KeyFile.java:79)
at
net.schmizz.sshj.userauth.keyprovider.BaseFileKeyProvider.getPublic(BaseFileKeyProvider.java:81)
at
net.schmizz.sshj.userauth.method.KeyedAuthMethod.putPubKey(KeyedAuthMethod.java:44)
... 9 more
…On Mon, Jan 14, 2019 at 11:40 AM Jeroen van Erp ***@***.***> wrote:
Is your private key protected by a passphrase? SSHJ tries to decrypt the
key. If it is not, I'd like to know the exact command to generate such a
key.
I agree that an NPE is bad, but before deciding on the solution I'd need
to know the above.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#484 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/APgMHphw8FAD2nTnQ6rDwrOIlQocsUHtks5vDF6QgaJpZM4Z8rZs>
.
|
Indeed, thanks for the reply. I also figured out that the RSA keytype in the new format does not work (yet). Will fix the following things:
Currently you could do it using the |
Duplicate for #276. |
When the authentication key (in
~/.ssh/id_rsa
) is in OpenSSH format, then theOpenSSHKeyV1KeyFile
key provider is used. InvokingSshClient.authPublicKey
with such key results in aNullPointerException
because thePasswordFinder pwdf
isnull
. As far as I can seeOpenSSHKeyV1KeyFile
cannot handle correctly the case where no password is provided.The following Java code can be used to reproduce the issue:
The output is:
This has been reproduced using Mac OS 10.14.2. An excerpt of my
id_rsa
contents:The text was updated successfully, but these errors were encountered: