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 (6448 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


Complete thread: