我在sharpssh中遇到了sftp.put的问题。我收到此错误消息:
Session.connect: System.Security.Cryptography.CryptographicException: Bad Data.
at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
at System.Security.Cryptography.Utils._ImportKey(SafeProvHandle hCSP, Int32 keyNumber, CspProviderFlags flags, Object cspObject, SafeKeyHandle& hKey)
at System.Security.Cryptography.DSACryptoServiceProvider.ImportParameters(DSAParameters parameters)
at Tamir.SharpSsh.jsch.jce.SignatureDSA.verify(Byte[] sig)
at Tamir.SharpSsh.jsch.DHG1.next(Buffer _buf)
at Tamir.SharpSsh.jsch.Session.connect(Int32 connectTimeout) `
代码:
Dim port = "22"
Dim host = "sftp.iceCream.com"
Dim Username = "softserve"
Dim Password = "chocolate"
Dim ftpFolder = "/toCREAM"
Dim fileName = "timbo.txt"
Dim sftp = New Sftp(host, Username, Password)
sftp.Connect(22)
sftp.Put(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), fileName), ftpFolder) '+ "/" + fileName)
sftp.Close()