使用SFTP连接到FTP站点并下载文件 [英] Connect to FTP site using SFTP and download files

查看:118
本文介绍了使用SFTP连接到FTP站点并下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从 FTP 站点下载所有文件。但我需要连接 SFTP 来连接。我无法找到示例/教程来使用 SFTP FTP 站点下载文件以进行连接。



有人可以请我指教一个教程,或者提供一些示例代码来开始吗?

解决方案

Tamir的 SharpSSH 库处理SFTP非常好。有很多例子,但要点是:
$ b $ pre $ sftp sftp = new Sftp(sftpHost,sftpUser);
Console.WriteLine(success);

//假设公钥/私钥认证在这里...
sftp.AddIdentityFile(privateKeyFileName,privateKeyFilePassPhrase);
sftp.Connect(sftpPort);
ArrayList files = sftp.GetFileList(。);
foreach(文件中的字符串文件)
{
Console.WriteLine(\ t {0},file);
}

sftp.Close();


I need to download all the files from a FTP site. But i need to connect SFTP to connect. I am unable to find examples/tutorials to download files from the FTP site using SFTP to connect.

Can someone please point me to a tutorial or provide some sample code to begin with ?

解决方案

Tamir's SharpSSH library handles SFTP pretty well. And there are plenty of examples, but the gist is:

Sftp sftp = new Sftp(sftpHost, sftpUser);
Console.WriteLine("success");

// assuming public/private key authentication here...
sftp.AddIdentityFile(privateKeyFileName, privateKeyFilePassPhrase);
sftp.Connect(sftpPort);
ArrayList files = sftp.GetFileList(".");                
foreach (string file in files)
{
Console.WriteLine("\t{0}", file);
}

sftp.Close();

这篇关于使用SFTP连接到FTP站点并下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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