wodSFTP.NET: Problems with PrivateKey - WeOnlyDo Discussion board

wodSFTP.NET: Problems with PrivateKey (wodSFTP / wodSFTP.NET / wodSFTPdll)

by mfleisch, Thursday, September 21, 2006, 09:59 (6639 days ago)

hi all,

We are using wodSFTP.NET, Version 2.1.1.3
Until now we used it for sftp-transfers with password-authentification. this works very well!
now i have to implement a private/public key authentification.

the keys are generated by using this code:
[code]
'Generate and Save PrivateKey
km.Generate(WeOnlyDo.Security.Cryptography.SSHKeyTypes.RSAKey)
km.Save(WeOnlyDo.Security.Cryptography.SSHKeyTypes.RSAKey, sFolder & & sPrivateKeyFilename, myPW )

'Save PublicKey
Dim fFile As File
Dim sWriter As StreamWriter
sWriter = fFile.CreateText(sFolder & & sPublicKeyFilename)
sWriter.WriteLine(km.PublicKeySSH(WeOnlyDo.Security.Cryptography.SSHKeyTypes.RSAKey))
sWriter.Close()
fFile = Nothing
[/code]

the code for connection:
[code]
Dim km As New WeOnlyDo.Security.Cryptography.KeyManager
Dim sFolder As String = c:mypath
Dim sPublicKeyFilename As String = ABC_SSH_PublicKey.rsa
Dim sPrivateKeyFilename As String = ABC_SSH_PrivateKey.rsa
Dim type As WeOnlyDo.Security.Cryptography.SSHKeyTypes
Try
type = km.Load(sFolder & & sPrivateKeyFilename, myPW )
Catch ex As Exception
'my exceptions
End Try


Sftp1.Port = chkNull(rdrFiles( n_PortID ))
Sftp1.Hostname = chkNull(rdrFiles( s_URL ))
Sftp1.Login = chkNull(rdrFiles( s_Loginname ))

Debug.WriteLine(km.PublicKeyOpenSSH(type)) ' this shows the correct public key
Sftp1.PrivateKey = km.PrivateKey(WeOnlyDo.Security.Cryptography.SSHKeyTypes.RSAKey) 'Sftp1.PrivateKey is now a byte array, including 627 times 0

Sftp1.Authentication = WeOnlyDo.Client.SFTP.Authentications.PublicKey
[/code]

THE PROBLEM:
The Sftp1.PrivateKey includes a byte-value with only 0 chars
=> the authentification fails with the message: Authentication with the server failed.

Can anyone help me please - i need a quick solution and have spend a lot of time until now to solve this - without success.
thx.
greets,
mike

Re: wodSFTP.NET: Problems with PrivateKey

by wodDamir, Thursday, September 21, 2006, 11:09 (6638 days ago) @ mfleisch

Hi Mike,

I see you're using a very old version of wodSFTP.Net. Please download a newer version or request an update from http://www.weonlydo.com/index.asp?update=1 (if you're are our customer). The current release is 3.0.6.38.

I Authenticated successfully using the following code:
---------------------------------------------
Dim WithEvents sftp1 As WeOnlyDo.Client.SFTP
Dim key As WeOnlyDo.Security.Cryptography.KeyManager
sftp1 = New WeOnlyDo.Client.SFTP
key = New WeOnlyDo.Security.Cryptography.KeyManager
key.Load( C:RSAPrivatekey.txt , your_password )
sftp1.PrivateKey = key.PrivateKey(WeOnlyDo.Security.Cryptography.SSHKeyTypes.RSAKey)
sftp1.Blocking = True
sftp1.Authentication = WeOnlyDo.Client.SFTP.Authentications.PublicKey
sftp1.Hostname = linux.weonlydo.com
sftp1.Login = test
sftp1.Connect()
---------------------------------------------

If you Fail to authenticate with your server with new version and code similiar to mine, please contact us at techsupport@weonlydo.com

Regards,
Damba