CentOS6.4 open FTP


ping

测试主机和虚拟机的连通性

ping 192.168.2.129

open ssh

ssh服务已经开启,关闭防火墙,主机和虚拟机能ping通

#查看ssh状态
service sshd status

#防火墙的状态
service iptables status


#开启ssh服务
service sshd start

#关闭防火墙
chkconfig iptables off

开启tftp和vsftpd

#启动vsftpd 服务
service vsftpd start

#查看vsftpd 的启动状态
service vsftpd status 

转载于:https://www.cnblogs.com/mysticbinary/articles/11305717.html

安全的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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值