2

I have a small C# app that uses the SharpSSH library to simply upload a file using SFTP. Now my client wants to use the same program to connect to another server using SSH/SFTP, however for some reason that server has been built using "SSH/SFTP over custom port 5929." No idea why they changed the port, however..

I have looked over all the documentation that I can find for SharpSSH but can find no mention of how I could direct it to use port 5929 vice the normal port 22. My thought would be to use HOSTNAME:5929 but not sure if that is correct.

Anyone have an answer?

4

2 回答 2

3

SshTransferProtocolBase有一个带有 1 个重载的连接方法。默认值不带参数,默认为端口 22。重载采用端口号。

所以:

SshTransferProtocolBase ftp = new SshTransferProtocolBase("host","user");
ftp.connect(5929);

以上应该工作。

于 2013-09-24T19:55:52.007 回答
3

Tamir.SharpSshConnect() 方法有一个重载,它接受一个整数并允许设置端口。

Tamir.SharpSsh.Sftp sftpClient = new Sftp(sftpServer, sftpUserName, sftpUserPassword);    
sftpClient.Connect(sftpPort);   
sftpClient.Close();
sftpClient = null;
于 2015-10-28T03:56:03.360 回答