Trouble using authPubkey authentication - WeOnlyDo Discussion board

Trouble using authPubkey authentication (wodSFTP / wodSFTP.NET / wodSFTPdll)

by Damiano, Wednesday, October 20, 2004, 09:46 (7341 days ago)

Hi, I'm developing a simple program in vc that has to extract a private key from a db and then do an ssh to an host using that key.

When I connect using password authentication everything works fine, but when I to use key auth the connect() method returns me a strange value (-2146798272).
I can't figure out what I'm doing wrong, can you help me ?

Thanks.

Damiano

Here's a sample of my code

m_SSH2->put_Blocking(VARIANT_TRUE);
m_SSH2->put_Hostname(ip);
m_SSH2->put_Login(user);
m_SSH2->put_Protocol(protocol);
m_SSH2->put_Authentication(authPubkey);
m_SSH2->put_Port(2222);

m_SSH2->put_Prompt(vExpectedPrompt);

//gets the private key from db
//row[1] holds is a pointer (char *) to the private key data
row= get_private_key();

numchar = (long) (strlen(row[1]));
Bufsize = (long) (sizeof(char *) * numchar);


SAFEARRAY *psa;
SAFEARRAYBOUND rgsabound[1];
char HUGEP *data;

rgsabound[0].lLbound=0;
rgsabound[0].cElements=Bufsize;

psa = SafeArrayCreate(VT_UI1,1,rgsabound);
if (!psa)
return WSA_NOT_ENOUGH_MEMORY;

SafeArrayAccessData(psa, (void HUGEP* FAR*)&data);

memcpy(data,row[1], Bufsize);
SafeArrayUnaccessData(psa);

VARIANT var;

var.vt =VT_ARRAY | VT_UI1;
var.parray=psa;

m_SSH2->put_PrivateKey(var);
ConnectRetCode = m_SSH2->Connect();
//Here ConnectRetCode is - 2146798272

Re: Trouble using authPubkey authentication

by wodSupport, Wednesday, October 20, 2004, 11:47 (7341 days ago) @ Damiano

Damiano,

error 2146798272 is in HEX 800A7540. Looking at last word HEX 7540 and convert it back to DEC is 30016 = Invalid login/password error.

So, let's see why you get this error. Did you upload public key to the server?

Re: Trouble using authPubkey authentication

by Damiano, Wednesday, October 20, 2004, 12:15 (7341 days ago) @ wodSupport

The key I'm using to connect with the server is taken from the server.
on the server I created a pair of private/public key using ssh-keygen -t dsa.
Then I inserted the private key into the db.
If I copy the private key on another linux system I can do a login with that key, so I think the system is ok.

I think it's a problem related to the conversion of the key in the code, so I will try to assign it directly in an array of chars.
Thanks for the support, I hope to write soon about my successful connection with a private key ! :)

Damiano,

error 2146798272 is in HEX 800A7540. Looking at last word HEX 7540 and convert it back to DEC is 30016 = Invalid login/password error.

So, let's see why you get this error. Did you upload public key to the server?

Re: Trouble using authPubkey authentication

by wodSupport, Wednesday, October 20, 2004, 12:17 (7341 days ago) @ Damiano

Damiano,

you said if you copy public key to another linux it works ok? With your current code? Then it could be server issue, not conversion issue?

Re: Trouble using authPubkey authentication

by Damiano, Wednesday, October 20, 2004, 12:32 (7341 days ago) @ wodSupport

Unfortunately no, if i copy my private key on another linux system and then I do an ssh from the command line (i.e ssh -i ./private_key -p 2222 host) it works.
My program doesn't work, so i think it's a string manipulation problem
I made some test but I saw that the text in the private key file is right, could it be an error in the variant conversion ?

Damiano,

you said if you copy public key to another linux it works ok? With your current code? Then it could be server issue, not conversion issue?

Re: Trouble using authPubkey authentication

by wodSupport, Wednesday, October 20, 2004, 13:46 (7340 days ago) @ Damiano

Damiano,

ok, I see. Do you have some spare key you could send to me, including your code? I don't have the database like you, but we could use some local file for storing/retrieving, right?

If I can duplicate the issue I will be able to give you much better explanation what could be going on.

Please send it to techsupport@weonlydo.com

Re: Trouble using authPubkey authentication

by Damiano, Wednesday, October 20, 2004, 14:15 (7340 days ago) @ wodSupport

Yes, I can send you some keys.
I cannot give you the access to the server (it's a testing server, we are using it as a test environment).
I've tried with a rsa and a dsa key.
I am sending you the 2 pairs and the source code.

Thanks

Damiano,

ok, I see. Do you have some spare key you could send to me, including your code? I don't have the database like you, but we could use some local file for storing/retrieving, right?

If I can duplicate the issue I will be able to give you much better explanation what could be going on.

Please send it to techsupport@weonlydo.com

Re: Trouble using authPubkey authentication

by A. McDermott, Monday, November 21, 2005, 23:58 (6943 days ago) @ Damiano

I am having a problem similar to the one already mentioned in this thread.

I use wodSFTP and wodSSH. I can properly transfer files between my program and a remote server using authPubkey and wodSFTP. I however cannot connect to the same remote sever using the same private key and settings with wodSSH.

with wodSSH, connect returns -2146798272 (explained in this thread). When I run the remote sshd in debug mode, it seems that wodSSH does not attempt to authenticate with my private key the same way the wodSFTP does.

wodSFTP:
[code]
debug1: userauth-request for user xyz service ssh-connection method none
debug1: userauth-request for user xyz service ssh-connection method publickey
[/code]

wodSSH:
[code]
debug1: userauth-request for user xyz service ssh-connection method none
[/code]

What can cause this type of situation? I am using the same private key for both the ssh and sftp code.

Re: Trouble using authPubkey authentication

by wodSupport, Tuesday, November 22, 2005, 00:00 (6943 days ago) @ A. McDermott

A.,

are you sure this is same error as discussed above?

Can you send your keys to techsupport@weonlydo.com so we can try this out and duplicate the behavior?

And, very important - do you use latest versions of both products?