SFTP SSH.NET DLL而不是SharpSSH [英] SFTP SSH.NET DLL instead of SharpSSH

查看:716
本文介绍了SFTP SSH.NET DLL而不是SharpSSH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一个免费的DLL .NET处理SFTP连接。

I was seeking for a free DLL for .net to handle SFTP connections.

我发现这个项目 SharpSSH ,但它缺乏的文档。

I found out this project SharpSSH, but it lacks of documentation.

我花了很多时间来如何的DLL工程。我创建了一个测试项目,我开始测试不同的功能。有些功能正在如删除文件。

I spent a lot of time to figure how the dll works. I created a test project and I started to test different functions. Some functions are working such as deleting files.

我有PUTFILE()函数和GETFILE一个问题()。

I have a problem with putfile() function and getfile().

下面的例子:

Dim ssh As SFTPUtil
ssh = New SFTPUtil("MY SERVER", "MY USER", "MY PW")
ssh.GetFile("/home/sftptest/test111.xml", "C:\\text.xml")

请注意,该GETFILE()的参数是:

Note that the getfile() parameters are:

Public Sub GetFile(remotePath As String, localPath As String)

我一步的功能,但我没有得到通过这些参数的正确方法。

I step in the functions, but I didn't get the correct way to pass those parameters.

我真的不知道我是否应该用斜线(/)或反斜杠()。我知道,Linux使用(/)

I dont really know if i should use slashes(/) or backslashes (). I know that Linux uses (/)

我注意到,例如,该C:\已经转变为C:\\。

I noticed for example that the "C:\" has been transformed to "C:\\".

刚刚提及的是,SFTP是在Linux机器上。

Just to mention that the SFTP is on a linux machine.

感谢你。

推荐答案

这是我应该做的(vb.net code)建立与的这个库( SSHnet ,我做的不可以使用SharpSHH:

Here's What I should have done (vb.net code) to establish the connection with THIS library (SSHnet), I did not use SharpSHH:

Private Sub ButtonAction_Click(sender As Object, e As System.EventArgs) Handles ButtonAction.Click

    Dim PasswordConnection = New PasswordAuthenticationMethod("test", "test")
    Dim KeyboardInteractive = New KeyboardInteractiveAuthenticationMethod("test")
    Dim ConnectionInfo = New ConnectionInfo("192.168.1.1", 22, "test", PasswordConnection, KeyboardInteractive)

    AddHandler KeyboardInteractive.AuthenticationPrompt, _
    Sub(_sender As Object, _e As Renci.SshNet.Common.AuthenticationPromptEventArgs)
        For Each prompt In _e.Prompts
            Debug.Print(prompt.Request)
            If Not prompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) = -1 Then
                prompt.Response = "test"
            End If
        Next
    End Sub

    sftp = New SftpClient(ConnectionInfo)
    sftp.Connect()

    sftp.disconnect()
End Sub

这篇关于SFTP SSH.NET DLL而不是SharpSSH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆