文件名称:Open Ftp SSH Tools
文件大小:919KB
文件格式:ZIP
更新时间:2014-04-11 05:26:01
OpenFtp SSHTools
安全的FTP传输 Imports Org.Mentalis.Security.Ssl Imports Org.Mentalis.Security.Certificates Imports Org.Mentalis.Security.Cryptography Imports System Imports System.IO Imports System.Exception 'Imports Tamir.SharpSsh.java 'Imports Tamir.SharpSsh Imports SharpSSH_EXD Public Class SFTPHelper Private Sub New() End Sub Private m_sshCp As SshTransferProtocolBase Public ReadOnly Property Connected() As Boolean Get Return m_sshCp.Connected End Get End Property Public Sub New(ByVal connectionInfo As SshConnectionInfo) m_sshCp = New Sftp(connectionInfo.Host, connectionInfo.User) If (Not connectionInfo.Pass Is Nothing) Then m_sshCp.Password = connectionInfo.Pass End If If Not connectionInfo.IdentityFile Is Nothing Then m_sshCp.AddIdentityFile(connectionInfo.IdentityFile) End If End Sub Public Sub Connect() If (m_sshCp.Connected = False) Then Try m_sshCp.Connect(10022) ' m_sshCp.Connect() ' Dim i As Integer = m_sshCp.Port Catch ex As System.Exception ' Dim str As String = ex.ToString ' Dim a As Integer = 0 m_sshCp.Close() End Try End If End Sub Public Sub Close() If (m_sshCp.Connected) Then m_sshCp.Close() End If End Sub Public Function Upload(ByVal localPath As String, ByVal remotePath As String) As String Try If (m_sshCp.Connected = False) Then m_sshCp.Connect(10022) End If Try m_sshCp.Put_resume(localPath, remotePath) 'm_sshCp.RemoveFile(remotePath) ' Return "Remote File has already exists. delete file" Catch ex As Tamir.SharpSsh.jsch.SftpException m_sshCp.RemoveFile(remotePath) Return "Remote File has already exists. delete file" End Try Return "" Catch ex As Exception Return ex.Message End Try End Function Public Function Download(ByVal remotePath As String, ByVal localPath As String) As Boolean Try If (m_sshCp.Connected = False) Then m_sshCp.Connect(10022) End If m_sshCp.Get(remotePath, localPath) Return True Catch Return False End Try End Function Public Function CheckFileLength(ByVal filePath As String) As Long Try 'Dim stream As New Tamir.SharpSsh.SshStream(filePath.Replace(".TMP", ".TXT"), m_sshCp.Username, m_sshCp.Password) 'Return stream.Length If (m_sshCp.Connected = False) Then m_sshCp.Connect(10022) End If Return m_sshCp.GetFileLength(filePath) Catch ex As Exception Dim str As String = ex.ToString End Try Return 0 End Function Public Sub SetFileLength(ByVal filePath As String) 'set 0 Try 'Dim stream As New Tamir.SharpSsh.SshStream(filePath.Replace(".TMP", ".TXT"), m_sshCp.Username, m_sshCp.Password) 'Return stream.Length If (m_sshCp.Connected = False) Then m_sshCp.Connect(10022) End If m_sshCp.SetFileLength(filePath) Catch ex As Exception Dim str As String = ex.ToString End Try End Sub Public Function RenameFile(ByVal oldPath As String, ByVal newPath As String) As Boolean Dim blnResult As Boolean = False Try If (m_sshCp.Connected = False) Then m_sshCp.Connect(10022) End If m_sshCp.RenameFile(oldPath, newPath) blnResult = True Catch ex As Exception blnResult = False End Try Return blnResult End Function End Class Public Class SshConnectionInfo Private _user As String Private _pass As String Private _host As String Private _identityFile As String Public Property User() As String Get Return _user End Get Set(ByVal value As String) _user = value End Set End Property Public Property Pass() As String Get Return _pass End Get Set(ByVal value As String) _pass = value End Set End Property Public Property Host() As String Get Return _host End Get Set(ByVal value As String) _host = value End Set End Property Public Property IdentityFile() As String Get Return _identityFile End Get Set(ByVal value As String) _identityFile = value End Set End Property End Class
【文件预览】:
SSHTools-SSHDaemon-Win32-0.0.9
----INSTALL.TXT(3KB)
----bin()
--------chkinstall.bat(260B)
--------findjava.bat(244B)
--------ssh-keygen.bat(1KB)
--------findfile.bat(153B)
--------Uninstall-SSHDaemon-Service.bat(773B)
--------sshd-start.bat(1KB)
--------cpappend.bat(27B)
--------Install-SSHDaemon-Service.bat(951B)
--------sshd-stop.bat(1KB)
--------Wrapper.exe(104KB)
----conf()
--------sshd-service.conf(4KB)
--------authorization.xml(200B)
--------server.xml(2KB)
--------windows.xml(1KB)
--------sshtools.xml(3KB)
----jni()
--------daemon()
----dist()
--------lib()
----LICENSE.TXT(18KB)
----lib()
--------wrapper.jar(29KB)
--------Wrapper.dll(48KB)
--------log4j-1.2.6.jar(342KB)