Discussion:
[JSch-users] addIdentity: on android getting invalid privatekey: [B@428ff138 with known good RSA key
Gerry Reno
2013-11-10 20:30:47 UTC
Permalink
Using JSch 1.50

I'm trying to get publickey auth working on arm android.

I have password auth working fine already.

So I added addIdentity( keypath ) but it always errors even with known good RSA key.

I tested the key both on the phone using ConnectBot and on two linux machines using openssh.

The key works fine from all three.

When I use the addIdentity method and pass the key path I'm always getting an error, invalid privatekey: [***@428ff138

Is there something else I need to add besides addIdentity to make this work?
Jung, Volker
2013-11-11 08:18:38 UTC
Permalink
Hello Gerry,

when using the addIdentity-Method taking only the private-key-path, the public key is expected to be in the same folder as the private key, having the same name as the private key with an additional suffix ".pub". (See KeyPair.load(JSch, String, String)). You might want to use one of the other addIdentity-Methods provided by the JSch-class to be independent of that default behavior.


-----Ursprüngliche Nachricht-----
Von: Gerry Reno [mailto:***@verizon.net]
Gesendet: Sonntag, 10. November 2013 21:31
An: jsch-***@lists.sourceforge.net
Betreff: [JSch-users] addIdentity: on android getting invalid privatekey: [***@428ff138 with known good RSA key

Using JSch 1.50

I'm trying to get publickey auth working on arm android.

I have password auth working fine already.

So I added addIdentity( keypath ) but it always errors even with known good RSA key.

I tested the key both on the phone using ConnectBot and on two linux machines using openssh.

The key works fine from all three.

When I use the addIdentity method and pass the key path I'm always getting an error, invalid privatekey: [***@428ff138

Is there something else I need to add besides addIdentity to make this work?
Gerry Reno
2013-11-11 15:23:02 UTC
Permalink
Hi Volker,

Thanks for the reply.

I should have mentioned that I already had both public and privat=
e keys in the same folder on the Android device.=20
The keys have the same prefix only difference is that .pub is added f=
or public key. Eg: id_rsa and id_rsa.pub.

I had read about needing the public key in the folder when I chec=
ked the method.

The perms on both files are rw-rw-r-- when I upload the keys. An=
d without a rooted phone I have no way to change
those permissions. Could this be a factor?

If so, I guess I could read the file into a String and call one o=
f the alternate methods although I'd really prefer
to just use the simpler method. Any way to get that working?
Post by Jung, Volker
Hello Gerry,
when using the addIdentity-Method taking only the private-key-path,=
the public key is expected to be in the same folder as the private k=
ey, having the same name as the private key with an additional suffix=
".pub". (See KeyPair.load(JSch, String, String)). You might want to =
use one of the other addIdentity-Methods provided by the JSch-class t=
o be independent of that default behavior.=20
Post by Jung, Volker
-----Urspr=FCngliche Nachricht-----
Gesendet: Sonntag, 10. November 2013 21:31
Betreff: [JSch-users] addIdentity: on android getting invalid priva=
Using JSch 1.50
I'm trying to get publickey auth working on arm android.
I have password auth working fine already.
So I added addIdentity( keypath ) but it always errors even with kn=
own good RSA key.
Post by Jung, Volker
I tested the key both on the phone using ConnectBot and on two linu=
x machines using openssh.
Post by Jung, Volker
The key works fine from all three.
When I use the addIdentity method and pass the key path I'm always =
Is there something else I need to add besides addIdentity to make t=
his work?
Post by Jung, Volker
-------------------------------------------------------------------=
-----------
Post by Jung, Volker
November Webinars for C, C++, Fortran Developers Accelerate applica=
tion performance with scalable programming models. Explore techniques=
for threading, error checking, porting, and tuning. Get the most fro=
m the latest Intel processors and coprocessors. See abstracts and reg=
ister http://pubads.g.doubleclick.net/gampad/clk?id=3D60136231&iu=
=3D/4140/ostg.clktrk
Post by Jung, Volker
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
-------------------------------------------------------------------=
-----------
Post by Jung, Volker
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models=
. Explore
Post by Jung, Volker
techniques for threading, error checking, porting, and tuning. Get =
the most=20
Post by Jung, Volker
from the latest Intel processors and coprocessors. See abstracts an=
d register
Post by Jung, Volker
http://pubads.g.doubleclick.net/gampad/clk?id=3D60136231&iu=3D/4140=
/ostg.clktrk
Post by Jung, Volker
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
Gerry Reno
2013-11-11 19:08:34 UTC
Permalink
Some further information.

I changed everything over to read both keyfiles into byte arrays priv=
atekey and publickey.

and then call addIdentity( name, privatekey, publickey, passphrase); =
// I just passed (byte[])null for passphrase since
there is none

and still I get same error: invalid privatekey: [***@41a9d1e0

When I dump the arrays to the Log as strings the keys are correct.
Post by Gerry Reno
Hi Volker,
Thanks for the reply.
I should have mentioned that I already had both public and priv=
ate keys in the same folder on the Android device.=20
Post by Gerry Reno
The keys have the same prefix only difference is that .pub is added=
for public key. Eg: id_rsa and id_rsa.pub.
Post by Gerry Reno
I had read about needing the public key in the folder when I ch=
ecked the method.
Post by Gerry Reno
The perms on both files are rw-rw-r-- when I upload the keys. =
And without a rooted phone I have no way to change
Post by Gerry Reno
those permissions. Could this be a factor?
If so, I guess I could read the file into a String and call one=
of the alternate methods although I'd really prefer
Post by Gerry Reno
to just use the simpler method. Any way to get that working?
Post by Jung, Volker
Hello Gerry,
when using the addIdentity-Method taking only the private-key-path=
, the public key is expected to be in the same folder as the private =
key, having the same name as the private key with an additional suffi=
x ".pub". (See KeyPair.load(JSch, String, String)). You might want to=
use one of the other addIdentity-Methods provided by the JSch-class =
to be independent of that default behavior.=20
Post by Gerry Reno
Post by Jung, Volker
-----Urspr=FCngliche Nachricht-----
Gesendet: Sonntag, 10. November 2013 21:31
Betreff: [JSch-users] addIdentity: on android getting invalid priv=
Using JSch 1.50
I'm trying to get publickey auth working on arm android.
I have password auth working fine already.
So I added addIdentity( keypath ) but it always errors even with k=
nown good RSA key.
Post by Gerry Reno
Post by Jung, Volker
I tested the key both on the phone using ConnectBot and on two lin=
ux machines using openssh.
Post by Gerry Reno
Post by Jung, Volker
The key works fine from all three.
When I use the addIdentity method and pass the key path I'm always=
Is there something else I need to add besides addIdentity to make =
this work?
Post by Gerry Reno
Post by Jung, Volker
------------------------------------------------------------------=
------------
Post by Gerry Reno
Post by Jung, Volker
November Webinars for C, C++, Fortran Developers Accelerate applic=
ation performance with scalable programming models. Explore technique=
s for threading, error checking, porting, and tuning. Get the most fr=
om the latest Intel processors and coprocessors. See abstracts and re=
gister http://pubads.g.doubleclick.net/gampad/clk?id=3D60136231&iu=
=3D/4140/ostg.clktrk
Post by Gerry Reno
Post by Jung, Volker
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
------------------------------------------------------------------=
------------
Post by Gerry Reno
Post by Jung, Volker
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming model=
s. Explore
Post by Gerry Reno
Post by Jung, Volker
techniques for threading, error checking, porting, and tuning. Get=
the most=20
Post by Gerry Reno
Post by Jung, Volker
from the latest Intel processors and coprocessors. See abstracts a=
nd register
Post by Gerry Reno
Post by Jung, Volker
http://pubads.g.doubleclick.net/gampad/clk?id=3D60136231&iu=3D/414=
0/ostg.clktrk
Post by Gerry Reno
Post by Jung, Volker
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
Shai Ayal
2013-11-11 19:39:35 UTC
Permalink
Maybe you can send us sample of the private key -- not this one, just
generate another one in the same way, see that it still doesn't work, and
send the keys to the list -- it would help a lot
Post by Gerry Reno
Some further information.
I changed everything over to read both keyfiles into byte arrays
privatekey and publickey.
and then call addIdentity( name, privatekey, publickey, passphrase); // I
just passed (byte[])null for passphrase since
there is none
When I dump the arrays to the Log as strings the keys are correct.
Post by Gerry Reno
Hi Volker,
Thanks for the reply.
I should have mentioned that I already had both public and private
keys in the same folder on the Android device.
Post by Gerry Reno
The keys have the same prefix only difference is that .pub is added for
public key. Eg: id_rsa and id_rsa.pub.
Post by Gerry Reno
I had read about needing the public key in the folder when I checked
the method.
Post by Gerry Reno
The perms on both files are rw-rw-r-- when I upload the keys. And
without a rooted phone I have no way to change
Post by Gerry Reno
those permissions. Could this be a factor?
If so, I guess I could read the file into a String and call one of
the alternate methods although I'd really prefer
Post by Gerry Reno
to just use the simpler method. Any way to get that working?
Post by Jung, Volker
Hello Gerry,
when using the addIdentity-Method taking only the private-key-path, the
public key is expected to be in the same folder as the private key, having
the same name as the private key with an additional suffix ".pub". (See
KeyPair.load(JSch, String, String)). You might want to use one of the other
addIdentity-Methods provided by the JSch-class to be independent of that
default behavior.
Post by Gerry Reno
Post by Jung, Volker
-----Ursprüngliche Nachricht-----
Gesendet: Sonntag, 10. November 2013 21:31
Betreff: [JSch-users] addIdentity: on android getting invalid
Using JSch 1.50
I'm trying to get publickey auth working on arm android.
I have password auth working fine already.
So I added addIdentity( keypath ) but it always errors even with known
good RSA key.
Post by Gerry Reno
Post by Jung, Volker
I tested the key both on the phone using ConnectBot and on two linux
machines using openssh.
Post by Gerry Reno
Post by Jung, Volker
The key works fine from all three.
When I use the addIdentity method and pass the key path I'm always
Is there something else I need to add besides addIdentity to make this
work?
------------------------------------------------------------------------------
Post by Gerry Reno
Post by Jung, Volker
November Webinars for C, C++, Fortran Developers Accelerate application
performance with scalable programming models. Explore techniques for
threading, error checking, porting, and tuning. Get the most from the
latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
Post by Gerry Reno
Post by Jung, Volker
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
------------------------------------------------------------------------------
Post by Gerry Reno
Post by Jung, Volker
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models.
Explore
Post by Gerry Reno
Post by Jung, Volker
techniques for threading, error checking, porting, and tuning. Get the
most
Post by Gerry Reno
Post by Jung, Volker
from the latest Intel processors and coprocessors. See abstracts and
register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
Post by Gerry Reno
Post by Jung, Volker
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models.
Explore
techniques for threading, error checking, porting, and tuning. Get the most
from the latest Intel processors and coprocessors. See abstracts and
register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
--
SPT <https://market.android.com/details?id=org.ayal.SPT> - persistent SSH
tunnels for android.
Gerry Reno
2013-11-11 19:52:51 UTC
Permalink
Hi Shai,

Ok, here is one of my key sets that fail:

-----BEGIN PRIVATE KEY-----
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALjYkwBTqhl5P8E
NLB5jOUeIybMI2DL7bmQ1wTpWC8KCBaeCQmgqB/dUS23qYPJuaiuRnqofC7vsqr
xdA3ci7Y+DivcXhxeq3mI6oJqrsr0zCRuqpS1nSas9etXFY88odSA3N1z45Fybs
X1aQl84Q/DD2XDxwA5g3tnPH1Fhqxz7AgMBAAECgYEAhn3t11sIdKhn3sr6wtFn
J8k7GGzjAZU3aOpDwXJB9DAudQat0qRiT26hw0O5biswTKsTSqx0GTPFtm/myZQ
8S+aYqj4r5B+PqkN6WQa7GaHSkksaYMJugEioo9L+Bv0Xfw7jgLcM5IGLpYdk5X
6v4PEIPYywtyh2Xfs9IGcjHUECQQDiUZZ9x7lrBRaVmK1n84712BgQraoK6i5Uo
mpu1nPsSPE7eGl0kLzP7wCZWkEDUjOVA4aW4CSM4RY/6jcKujuDAkEA0RaVdMGy
U2nU+uIxa2jvraHG8qdeyPl9bfDP3PlSEfCiI7JThEDsD551LZlCEmJVOBA6Feg
/E4xXxOujzD0HKQJAd745RLWOyiv4BhCw9wYrxrGeEf0AsiOzfb4tWBWJYiQ51o
BgM3d9HvtSstDJAyvT9OzXoi5XyF4zen++vaNJZwJBAJW7KoRWQbHiVBbl7KYSm
7En7STQHtylbeFRVknUcaVPQY12osBPDb2RqDBjVCF+MbDYTgBqNOF221O1u7MC
8SECQHNH2382GUgOATtd9/Cp7SZg0WvW5tsBjFHRgIu0L0Q2OzE9mJCH2TBwzOj
2wcgkEsvyeP1BxtKC0tS6vniUoAw=3D
-----END PRIVATE KEY-----

ssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAAAgQC42JMAU6oZeT/BDSweYzlHiMmzCNgy+25kNcE6V=
gvCggWngkJoKgf3VEtt6mDybmorkZ6qHwu77Kq8XQN3Iu2Pg4r3F4cXqt5iOqCaq7K9Mw=
kbqqUtZ0mrPXrVxWPPKHUgNzdc+ORcm7F9WkJfOEPww9lw8cAOYN7Zzx9RYasc+w=3D=
=3D
phonekey
Maybe you can send us sample of the private key -- not this one, j=
ust generate another one in the same way, see that
it still doesn't work, and send the keys to the list -- it would he=
lp a lot
Some further information.
I changed everything over to read both keyfiles into byte array=
s privatekey and publickey.
and then call addIdentity( name, privatekey, publickey, passphr=
ase); // I just passed (byte[])null for passphrase
since
there is none
When I dump the arrays to the Log as strings the keys are corre=
ct.
Post by Gerry Reno
Hi Volker,
Thanks for the reply.
I should have mentioned that I already had both public an=
d private keys in the same folder on the Android
device.
Post by Gerry Reno
The keys have the same prefix only difference is that .pub is=
added for public key. Eg: id_rsa and id_rsa.pub.
Post by Gerry Reno
I had read about needing the public key in the folder whe=
n I checked the method.
Post by Gerry Reno
The perms on both files are rw-rw-r-- when I upload the k=
eys. And without a rooted phone I have no way to
change
Post by Gerry Reno
those permissions. Could this be a factor?
If so, I guess I could read the file into a String and ca=
ll one of the alternate methods although I'd really
prefer
Post by Gerry Reno
to just use the simpler method. Any way to get that working?
Post by Jung, Volker
Hello Gerry,
when using the addIdentity-Method taking only the private-ke=
y-path, the public key is expected to be in the
same folder as the private key, having the same name as the pri=
vate key with an additional suffix ".pub". (See
KeyPair.load(JSch, String, String)). You might want to use one =
of the other addIdentity-Methods provided by the
JSch-class to be independent of that default behavior.
Post by Gerry Reno
Post by Jung, Volker
-----Urspr=FCngliche Nachricht-----
zon.net>]
Post by Gerry Reno
Post by Jung, Volker
Gesendet: Sonntag, 10. November 2013 21:31
s.sourceforge.net>
Post by Gerry Reno
Post by Jung, Volker
Betreff: [JSch-users] addIdentity: on android getting invali=
Using JSch 1.50
I'm trying to get publickey auth working on arm android.
I have password auth working fine already.
So I added addIdentity( keypath ) but it always errors even =
with known good RSA key.
Post by Gerry Reno
Post by Jung, Volker
I tested the key both on the phone using ConnectBot and on t=
wo linux machines using openssh.
Post by Gerry Reno
Post by Jung, Volker
The key works fine from all three.
When I use the addIdentity method and pass the key path I'm =
Is there something else I need to add besides addIdentity to=
make this work?
Post by Gerry Reno
Post by Jung, Volker
------------------------------------------------------------=
------------------
Post by Gerry Reno
Post by Jung, Volker
November Webinars for C, C++, Fortran Developers Accelerate =
application performance with scalable programming
models. Explore techniques for threading, error checking, porti=
ng, and tuning. Get the most from the latest Intel
processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=3D60136231&iu=
=3D/4140/ostg.clktrk
Post by Gerry Reno
Post by Jung, Volker
_______________________________________________
JSch-users mailing list
urceforge.net>
Post by Gerry Reno
Post by Jung, Volker
https://lists.sourceforge.net/lists/listinfo/jsch-users
------------------------------------------------------------=
------------------
Post by Gerry Reno
Post by Jung, Volker
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming=
models. Explore
Post by Gerry Reno
Post by Jung, Volker
techniques for threading, error checking, porting, and tunin=
g. Get the most
Post by Gerry Reno
Post by Jung, Volker
from the latest Intel processors and coprocessors. See abstr=
acts and register
Post by Gerry Reno
Post by Jung, Volker
http://pubads.g.doubleclick.net/gampad/clk?id=3D60136231&iu=
=3D/4140/ostg.clktrk
Post by Gerry Reno
Post by Jung, Volker
_______________________________________________
JSch-users mailing list
urceforge.net>
Post by Gerry Reno
Post by Jung, Volker
https://lists.sourceforge.net/lists/listinfo/jsch-users
---------------------------------------------------------------=
---------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming mo=
dels. Explore
techniques for threading, error checking, porting, and tuning. =
Get the most
from the latest Intel processors and coprocessors. See abstract=
s and register
http://pubads.g.doubleclick.net/gampad/clk?id=3D60136231&iu=
=3D/4140/ostg.clktrk
_______________________________________________
JSch-users mailing list
eforge.net>
https://lists.sourceforge.net/lists/listinfo/jsch-users
--=20
SPT <https://market.android.com/details?id=3Dorg.ayal.SPT> - persis=
tent SSH tunnels for android.
Shai Ayal
2013-11-11 20:25:03 UTC
Permalink
A few pointers:
try to see if the jsch example
http://www.jcraft.com/jsch/examples/UserAuthPubKey.java
works for you with this key (on a linux machine of course).
If it does, then this is an android problem - Maybe you should add the
bouncycastle library to your project -- see my application:
https://code.google.com/p/ssh-persistent-tunnel/source/browse/src/org/ayal/SPT/Main.java#91
and the README
https://code.google.com/p/ssh-persistent-tunnel/source/browse/README.build

If it doesn't work on linux, then this is key problem ....
Post by Gerry Reno
Hi Shai,
-----BEGIN PRIVATE KEY-----
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALjYkwBTqhl5P8E
NLB5jOUeIybMI2DL7bmQ1wTpWC8KCBaeCQmgqB/dUS23qYPJuaiuRnqofC7vsqr
xdA3ci7Y+DivcXhxeq3mI6oJqrsr0zCRuqpS1nSas9etXFY88odSA3N1z45Fybs
X1aQl84Q/DD2XDxwA5g3tnPH1Fhqxz7AgMBAAECgYEAhn3t11sIdKhn3sr6wtFn
J8k7GGzjAZU3aOpDwXJB9DAudQat0qRiT26hw0O5biswTKsTSqx0GTPFtm/myZQ
8S+aYqj4r5B+PqkN6WQa7GaHSkksaYMJugEioo9L+Bv0Xfw7jgLcM5IGLpYdk5X
6v4PEIPYywtyh2Xfs9IGcjHUECQQDiUZZ9x7lrBRaVmK1n84712BgQraoK6i5Uo
mpu1nPsSPE7eGl0kLzP7wCZWkEDUjOVA4aW4CSM4RY/6jcKujuDAkEA0RaVdMGy
U2nU+uIxa2jvraHG8qdeyPl9bfDP3PlSEfCiI7JThEDsD551LZlCEmJVOBA6Feg
/E4xXxOujzD0HKQJAd745RLWOyiv4BhCw9wYrxrGeEf0AsiOzfb4tWBWJYiQ51o
BgM3d9HvtSstDJAyvT9OzXoi5XyF4zen++vaNJZwJBAJW7KoRWQbHiVBbl7KYSm
7En7STQHtylbeFRVknUcaVPQY12osBPDb2RqDBjVCF+MbDYTgBqNOF221O1u7MC
8SECQHNH2382GUgOATtd9/Cp7SZg0WvW5tsBjFHRgIu0L0Q2OzE9mJCH2TBwzOj
2wcgkEsvyeP1BxtKC0tS6vniUoAw=
-----END PRIVATE KEY-----
ssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAAAgQC42JMAU6oZeT/BDSweYzlHiMmzCNgy+25kNcE6VgvCggWngkJoKgf3VEtt6mDybmorkZ6qHwu77Kq8XQN3Iu2Pg4r3F4cXqt5iOqCaq7K9MwkbqqUtZ0mrPXrVxWPPKHUgNzdc+ORcm7F9WkJfOEPww9lw8cAOYN7Zzx9RYasc+w==
phonekey
Post by Shai Ayal
Maybe you can send us sample of the private key -- not this one, just
generate another one in the same way, see that
Post by Shai Ayal
it still doesn't work, and send the keys to the list -- it would help a
lot
Post by Shai Ayal
Some further information.
I changed everything over to read both keyfiles into byte arrays
privatekey and publickey.
Post by Shai Ayal
and then call addIdentity( name, privatekey, publickey, passphrase);
// I just passed (byte[])null for passphrase
Post by Shai Ayal
since
there is none
When I dump the arrays to the Log as strings the keys are correct.
Post by Gerry Reno
Hi Volker,
Thanks for the reply.
I should have mentioned that I already had both public and
private keys in the same folder on the Android
Post by Shai Ayal
device.
Post by Gerry Reno
The keys have the same prefix only difference is that .pub is
added for public key. Eg: id_rsa and id_rsa.pub.
Post by Shai Ayal
Post by Gerry Reno
I had read about needing the public key in the folder when I
checked the method.
Post by Shai Ayal
Post by Gerry Reno
The perms on both files are rw-rw-r-- when I upload the keys.
And without a rooted phone I have no way to
Post by Shai Ayal
change
Post by Gerry Reno
those permissions. Could this be a factor?
If so, I guess I could read the file into a String and call
one of the alternate methods although I'd really
Post by Shai Ayal
prefer
Post by Gerry Reno
to just use the simpler method. Any way to get that working?
Post by Jung, Volker
Hello Gerry,
when using the addIdentity-Method taking only the
private-key-path, the public key is expected to be in the
Post by Shai Ayal
same folder as the private key, having the same name as the private
key with an additional suffix ".pub". (See
Post by Shai Ayal
KeyPair.load(JSch, String, String)). You might want to use one of
the other addIdentity-Methods provided by the
Post by Shai Ayal
JSch-class to be independent of that default behavior.
Post by Gerry Reno
Post by Jung, Volker
-----Ursprüngliche Nachricht-----
Gesendet: Sonntag, 10. November 2013 21:31
Betreff: [JSch-users] addIdentity: on android getting invalid
Using JSch 1.50
I'm trying to get publickey auth working on arm android.
I have password auth working fine already.
So I added addIdentity( keypath ) but it always errors even with
known good RSA key.
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
I tested the key both on the phone using ConnectBot and on two
linux machines using openssh.
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
The key works fine from all three.
When I use the addIdentity method and pass the key path I'm
Is there something else I need to add besides addIdentity to make
this work?
------------------------------------------------------------------------------
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
November Webinars for C, C++, Fortran Developers Accelerate
application performance with scalable programming
Post by Shai Ayal
models. Explore techniques for threading, error checking, porting,
and tuning. Get the most from the latest Intel
Post by Shai Ayal
processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
------------------------------------------------------------------------------
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming
models. Explore
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
techniques for threading, error checking, porting, and tuning.
Get the most
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
from the latest Intel processors and coprocessors. See abstracts
and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
------------------------------------------------------------------------------
Post by Shai Ayal
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models.
Explore
Post by Shai Ayal
techniques for threading, error checking, porting, and tuning. Get
the most
Post by Shai Ayal
from the latest Intel processors and coprocessors. See abstracts and
register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
Post by Shai Ayal
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
--
SPT <https://market.android.com/details?id=org.ayal.SPT> - persistent
SSH tunnels for android.
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models.
Explore
techniques for threading, error checking, porting, and tuning. Get the most
from the latest Intel processors and coprocessors. See abstracts and
register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
--
SPT <https://market.android.com/details?id=org.ayal.SPT> - persistent SSH
tunnels for android.
Gerry Reno
2013-11-11 22:35:22 UTC
Permalink
Result of test on Linux machine:

$ java -cp ".:jsch-0.1.50.jar" UserAuthPubKey
You chose /home/greno/.ssh/id_rsa.
com.jcraft.jsch.JSchException: invalid privatekey: [***@8814e9

This machine has both the private and public key in ~/.ssh/

id_rsa
id_rsa.pub

And I can log into this machine successfully using this same key from=
the phone using ConnectBot and from other Linux
machines using OpenSSH.
Post by Shai Ayal
try to see if the jsch example
http://www.jcraft.com/jsch/examples/UserAuthPubKey.java
works for you with this key (on a linux machine of course).
If it does, then this is an android problem - Maybe you should add =
the bouncycastle library to your project -- see my
Post by Shai Ayal
https://code.google.com/p/ssh-persistent-tunnel/source/browse/src/o=
rg/ayal/SPT/Main.java#91
Post by Shai Ayal
and the README
https://code.google.com/p/ssh-persistent-tunnel/source/browse/READM=
E.build
Post by Shai Ayal
If it doesn't work on linux, then this is key problem ....
Hi Shai,
-----BEGIN PRIVATE KEY-----
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALjYkwBTqhl5P8E
NLB5jOUeIybMI2DL7bmQ1wTpWC8KCBaeCQmgqB/dUS23qYPJuaiuRnqofC7vsqr
xdA3ci7Y+DivcXhxeq3mI6oJqrsr0zCRuqpS1nSas9etXFY88odSA3N1z45Fybs
X1aQl84Q/DD2XDxwA5g3tnPH1Fhqxz7AgMBAAECgYEAhn3t11sIdKhn3sr6wtFn
J8k7GGzjAZU3aOpDwXJB9DAudQat0qRiT26hw0O5biswTKsTSqx0GTPFtm/myZQ
8S+aYqj4r5B+PqkN6WQa7GaHSkksaYMJugEioo9L+Bv0Xfw7jgLcM5IGLpYdk5X
6v4PEIPYywtyh2Xfs9IGcjHUECQQDiUZZ9x7lrBRaVmK1n84712BgQraoK6i5Uo
mpu1nPsSPE7eGl0kLzP7wCZWkEDUjOVA4aW4CSM4RY/6jcKujuDAkEA0RaVdMGy
U2nU+uIxa2jvraHG8qdeyPl9bfDP3PlSEfCiI7JThEDsD551LZlCEmJVOBA6Feg
/E4xXxOujzD0HKQJAd745RLWOyiv4BhCw9wYrxrGeEf0AsiOzfb4tWBWJYiQ51o
BgM3d9HvtSstDJAyvT9OzXoi5XyF4zen++vaNJZwJBAJW7KoRWQbHiVBbl7KYSm
7En7STQHtylbeFRVknUcaVPQY12osBPDb2RqDBjVCF+MbDYTgBqNOF221O1u7MC
8SECQHNH2382GUgOATtd9/Cp7SZg0WvW5tsBjFHRgIu0L0Q2OzE9mJCH2TBwzOj
2wcgkEsvyeP1BxtKC0tS6vniUoAw=3D
-----END PRIVATE KEY-----
ssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAAAgQC42JMAU6oZeT/BDSweYzlHiMmzCNgy+25=
kNcE6VgvCggWngkJoKgf3VEtt6mDybmorkZ6qHwu77Kq8XQN3Iu2Pg4r3F4cXqt5iOqCa=
q7K9MwkbqqUtZ0mrPXrVxWPPKHUgNzdc+ORcm7F9WkJfOEPww9lw8cAOYN7Zzx9RYasc+=
w=3D=3D
Post by Shai Ayal
phonekey
Maybe you can send us sample of the private key -- not this =
one, just generate another one in the same way, see
Post by Shai Ayal
that
it still doesn't work, and send the keys to the list -- it wo=
uld help a lot
Post by Shai Ayal
Some further information.
I changed everything over to read both keyfiles into byte=
arrays privatekey and publickey.
Post by Shai Ayal
and then call addIdentity( name, privatekey, publickey, p=
assphrase); // I just passed (byte[])null for
Post by Shai Ayal
passphrase
since
there is none
d1e0
Post by Shai Ayal
When I dump the arrays to the Log as strings the keys are=
correct.
Post by Shai Ayal
Post by Gerry Reno
Hi Volker,
Thanks for the reply.
I should have mentioned that I already had both pub=
lic and private keys in the same folder on the Android
Post by Shai Ayal
device.
Post by Gerry Reno
The keys have the same prefix only difference is that .=
pub is added for public key. Eg: id_rsa and
Post by Shai Ayal
id_rsa.pub.
Post by Gerry Reno
I had read about needing the public key in the fold=
er when I checked the method.
Post by Shai Ayal
Post by Gerry Reno
The perms on both files are rw-rw-r-- when I upload=
the keys. And without a rooted phone I have no way to
Post by Shai Ayal
change
Post by Gerry Reno
those permissions. Could this be a factor?
If so, I guess I could read the file into a String =
and call one of the alternate methods although I'd
Post by Shai Ayal
really
prefer
Post by Gerry Reno
to just use the simpler method. Any way to get that wo=
rking?
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
Hello Gerry,
when using the addIdentity-Method taking only the priv=
ate-key-path, the public key is expected to be in the
Post by Shai Ayal
same folder as the private key, having the same name as t=
he private key with an additional suffix ".pub". (See
Post by Shai Ayal
KeyPair.load(JSch, String, String)). You might want to us=
e one of the other addIdentity-Methods provided by the
Post by Shai Ayal
JSch-class to be independent of that default behavior.
Post by Gerry Reno
Post by Jung, Volker
-----Urspr=FCngliche Nachricht-----
Gesendet: Sonntag, 10. November 2013 21:31
ts.sourceforge.net>>
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
Betreff: [JSch-users] addIdentity: on android getting =
Using JSch 1.50
I'm trying to get publickey auth working on arm andro=
id.
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
I have password auth working fine already.
So I added addIdentity( keypath ) but it always errors=
even with known good RSA key.
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
I tested the key both on the phone using ConnectBot an=
d on two linux machines using openssh.
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
The key works fine from all three.
When I use the addIdentity method and pass the key pat=
Is there something else I need to add besides addIdent=
ity to make this work?
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
------------------------------------------------------=
------------------------
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
November Webinars for C, C++, Fortran Developers Accel=
erate application performance with scalable programming
Post by Shai Ayal
models. Explore techniques for threading, error checking,=
porting, and tuning. Get the most from the latest
Post by Shai Ayal
Intel
processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=3D60136231&=
iu=3D/4140/ostg.clktrk
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
_______________________________________________
JSch-users mailing list
sts.sourceforge.net>
ts.sourceforge.net>>
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
https://lists.sourceforge.net/lists/listinfo/jsch-user=
s
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
------------------------------------------------------=
------------------------
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable progr=
amming models. Explore
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
techniques for threading, error checking, porting, and=
tuning. Get the most
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
from the latest Intel processors and coprocessors. See=
abstracts and register
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
http://pubads.g.doubleclick.net/gampad/clk?id=3D601362=
31&iu=3D/4140/ostg.clktrk
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
_______________________________________________
JSch-users mailing list
sts.sourceforge.net>
ts.sourceforge.net>>
Post by Shai Ayal
Post by Gerry Reno
Post by Jung, Volker
https://lists.sourceforge.net/lists/listinfo/jsch-user=
s
Post by Shai Ayal
---------------------------------------------------------=
---------------------
Post by Shai Ayal
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programm=
ing models. Explore
Post by Shai Ayal
techniques for threading, error checking, porting, and tu=
ning. Get the most
Post by Shai Ayal
from the latest Intel processors and coprocessors. See ab=
stracts and register
Post by Shai Ayal
http://pubads.g.doubleclick.net/gampad/clk?id=3D60136231&=
iu=3D/4140/ostg.clktrk
Post by Shai Ayal
_______________________________________________
JSch-users mailing list
.sourceforge.net>
ts.sourceforge.net>>
Post by Shai Ayal
https://lists.sourceforge.net/lists/listinfo/jsch-users
--
SPT <https://market.android.com/details?id=3Dorg.ayal.SPT> - =
persistent SSH tunnels for android.
Post by Shai Ayal
---------------------------------------------------------------=
---------------
Post by Shai Ayal
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming mo=
dels. Explore
Post by Shai Ayal
techniques for threading, error checking, porting, and tuning. =
Get the most
Post by Shai Ayal
from the latest Intel processors and coprocessors. See abstract=
s and register
Post by Shai Ayal
http://pubads.g.doubleclick.net/gampad/clk?id=3D60136231&iu=
=3D/4140/ostg.clktrk
Post by Shai Ayal
_______________________________________________
JSch-users mailing list
eforge.net>
Post by Shai Ayal
https://lists.sourceforge.net/lists/listinfo/jsch-users
--=20
SPT <https://market.android.com/details?id=3Dorg.ayal.SPT> - persis=
tent SSH tunnels for android.
Atsuhiko Yamanaka
2013-11-12 07:50:41 UTC
Permalink
This post might be inappropriate. Click to display it.
Gerry Reno
2013-11-12 15:12:33 UTC
Permalink
Thank you for the reply.

The converted key works fine.

We can use this conversion method for now until JSch has support for PKCS#8.
Post by Atsuhiko Yamanaka
Hi,
|_Date: Mon, 11 Nov 2013 14:52:51 -0500 __
|
|-----BEGIN PRIVATE KEY-----
|MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALjYkwBTqhl5P8E
|NLB5jOUeIybMI2DL7bmQ1wTpWC8KCBaeCQmgqB/dUS23qYPJuaiuRnqofC7vsqr
...
JSch has expected PKCS#5 private keys, which usually start with
-----BEGIN RSA PRIVATE KEY----- or
-----BEGIN DSA PRIVATE KEY-----
, but it seems your key is in PKCS#8 format.
Some hacks will be required to support such a format.
If you can't wait for that hack, you may want to convert it into PKCS#5 format,
$ openssl ras -in your_key -out your_new_key
Sincerely,
--
Atsuhiko Yamanaka
JCraft,Inc.
1-14-20 HONCHO AOBA-KU,
SENDAI, MIYAGI 980-0014 Japan.
Tel +81-22-723-2150
Skype callto://jcraft/
Twitter: http://twitter.com/ymnk
Facebook: http://facebook.com/aymnk
Atsuhiko Yamanaka
2014-02-12 13:07:47 UTC
Permalink
Hi,

+-From: Gerry Reno <***@verizon.net> ---
|_Date: Tue, 12 Nov 2013 10:12:33 -0500 __
|
|We can use this conversion method for now until JSch has support for PKCS#8.

We have improved code to support PCKS#8 private keys.
If you are interested in it, please try
http://www.jcraft.com/jsch/jsch-0.1.51-rc7.zip
There is no changes for APIs, and the method JSch#addIdentity(String prvkey)
will accept PCKS#8 private keys. So, you don't have to make any changes for
your code.


Sincerely,
--
Atsuhiko Yamanaka
JCraft,Inc.
1-14-20 HONCHO AOBA-KU,
SENDAI, MIYAGI 980-0014 Japan.
Tel +81-22-723-2150
Skype callto://jcraft/
Twitter: http://twitter.com/ymnk
Facebook: http://facebook.com/aymnk

Guruprasad Ds
2013-11-12 03:46:46 UTC
Permalink
Hi Team,

I don't want to get mails from this community any more. Please unsubscribe
me from this list.

Thanks you very much.

Regards,
Guru Prasad



From:
Gerry Reno <***@verizon.net>
To:
jsch-***@lists.sourceforge.net
Date:
11/11/2013 08:53 PM
Subject:
Re: [JSch-users] addIdentity: on android getting invalid privatekey:
[***@428ff138 with known good RSA key



Hi Volker,

Thanks for the reply.

I should have mentioned that I already had both public and private
keys in the same folder on the Android device.
The keys have the same prefix only difference is that .pub is added for
public key. Eg: id_rsa and id_rsa.pub.

I had read about needing the public key in the folder when I checked
the method.

The perms on both files are rw-rw-r-- when I upload the keys. And
without a rooted phone I have no way to change
those permissions. Could this be a factor?

If so, I guess I could read the file into a String and call one of the
alternate methods although I'd really prefer
to just use the simpler method. Any way to get that working?
Post by Jung, Volker
Hello Gerry,
when using the addIdentity-Method taking only the private-key-path, the
public key is expected to be in the same folder as the private key, having
the same name as the private key with an additional suffix ".pub". (See
KeyPair.load(JSch, String, String)). You might want to use one of the
other addIdentity-Methods provided by the JSch-class to be independent of
that default behavior.
Post by Jung, Volker
-----Ursprüngliche Nachricht-----
Gesendet: Sonntag, 10. November 2013 21:31
Betreff: [JSch-users] addIdentity: on android getting invalid
Using JSch 1.50
I'm trying to get publickey auth working on arm android.
I have password auth working fine already.
So I added addIdentity( keypath ) but it always errors even with known good RSA key.
I tested the key both on the phone using ConnectBot and on two linux machines using openssh.
The key works fine from all three.
When I use the addIdentity method and pass the key path I'm always
Is there something else I need to add besides addIdentity to make this work?
------------------------------------------------------------------------------
Post by Jung, Volker
November Webinars for C, C++, Fortran Developers Accelerate application
performance with scalable programming models. Explore techniques for
threading, error checking, porting, and tuning. Get the most from the
latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
Post by Jung, Volker
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
------------------------------------------------------------------------------
Post by Jung, Volker
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models.
Explore
Post by Jung, Volker
techniques for threading, error checking, porting, and tuning. Get the
most
Post by Jung, Volker
from the latest Intel processors and coprocessors. See abstracts and
register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
Post by Jung, Volker
_______________________________________________
JSch-users mailing list
https://lists.sourceforge.net/lists/listinfo/jsch-users
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models.
Explore
techniques for threading, error checking, porting, and tuning. Get the
most
from the latest Intel processors and coprocessors. See abstracts and
register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk

_______________________________________________
JSch-users mailing list
JSch-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users


=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
Loading...