Subject: Re: forward_listen + forward_accept + channel_read problem

Re: forward_listen + forward_accept + channel_read problem

From: Paresh Thakor <paresh.thakor_at_moontechnolabs.com>
Date: Wed, 18 Aug 2010 14:22:24 +0530

Hi Alexandr,

I'm also working on libssh2 API. And my issues is with libssh2_userauth_publickey_fromfile(). I'm using apple's sample code with
- (void)generateKeyPairPlease{
}

and
SecKeyGeneratePair()
inside the above method. You can take a look at apple's sample code for this.

Now, i need to encode keys to log or take them as string, so, i can write these keys into files which are accessible to libssh2 function because it needs filepath, right? But i always have -1 (error) as output. I don't know if i'm having few mistakes writing keypair. i've written keys into id_rsa and id_rsa.pub inside documents folder.

Few weeks back i'd tried system('ssh-keygen') also but this will not work on device, so, we need to get into Security.framework. So, I used the above code. I've use other application to test correct public key but it returns different key.

Private key i'm getting is:
MIUAAAAEvzANBgkqhkiG9w0BAQEFAAOFAAAABKkAMIIEpAIBAAKCAQEAiTbE//ms
cOUNASa2kM0xcvuUOX2abuTVze883U7uO8QvdQSKuOCOYp5Lm7ZWCSig/F9cAQJ5
qE5ZCEgLWrBYA4qcpHBb9cM5d6B1g5qIejjw11y7v3LmRoLYbC1qeZQ5S0YZh18L
30cVHQiwYfDw9T0M5vgJ7p1UwmtuM4SwT2+G05iiqKrJwugkFRZLC47haRIWF6IX
2i2GlPoW7cxLKsHITFcp+UlTLqa7E345yUTsIdig59uuMr1Ro9nwQUOrgiaA7rNo
xIMJwZ7FW94hrOe0TsJndrudhiIp18c6tfd4U1puyFQpyWxcHvR6C3VrcOaidCEx
cGRR0NsfToun9wIDAQABAoIBAQCBmNxKVLv9SSmWO8VVUKjyzBE8l5hkQvh5cAuR
jzpN8sdMA8UuRtHU7WPGJ1ptfhVHKJ4SSg8z2wQWYU1wE3ydo669VW5V2lUN2t0D
NtLOdbdsAadGdLRwRqc4zVBykn/my8fS5v+knFOhv5Iwf0xmpInqIL3oxGrI0oUc
XafU7ZFpXLZQdG1anesMmVQvTF+H0kGQXa8eMd3MKCxIsewP/HHgAE90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QEAiTbE//mscOUNASa2kM0x
cvuUOX2abuTVze883U7uO8QvdQSKuOCOYp5Lm7ZWCSig/F9cAQJ5qE5ZCEgLWrBY
A4qcpHBb9cM5d6B1g5qIejjw11y7v3LmRoLYbC1qeZQ5S0YZh18L30cVHQiwYfDw
9T0M5vgJ7p1UwmtuM4SwT2+G05iiqKrJwugkFRZLC47haRIWF6IX2i2GlPoW7cxL
KsHITFcp+UlTLqa7E345yUTsIdig59uuMr1Ro9nwQUOrgiaA7rNoxIMJwZ7FW94h
rOe0TsJndrudhiIp18c6tfd4U1puyFQpyWxcHvR6C3VrcOaidCExcGRR0NsfToun
9wIDAQAB

I'm writing the same format or content into id_rsa and id_rsa.pub file, is that correct or we need to write these keys into some special format? Please let me know if we have to about few format specification guide.

I don't know why my code is not working, what i get is wrong..! Please help me if you have any solution.

Regards,
Paresh Thakor.

On Aug 18, 2010, at 10:09 AM, Alexandr Piskun wrote:

> Good day. I have some problems when try to use libssh2 project.
> I compiled direct_tcpip.c example - works great.
> But i need forward tunnel.
> So i decide to use libssh2_channel_forward_listen and libssh2_channel_forward_accept functions.
> But i cant read from channel that libssh2_channel_forward_accept functions creates.
> libssh2_channel_read blocks. Maybe that function didnt see inbound daya.(i send data throw telnet).
> And i easy can write data to telnet with help of libssh2_channel_write function. But read fails, as i say.
> Maybe i miss something.
> Can u help me with my problem?
> _______________________________________________
> libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-08-18