When connect SFTP with SSH.NET and a proxy i get this error when connect :
KO > Exception :
Message : 'SOCKS5: Connection not allowed by ruleset.'
StackTrace :
at Renci.SshNet.Connection.Socks5Connector.HandleProxyConnect(IConnectionInfo connectionInfo, Socket socket)
at Renci.SshNet.Connection.Socks5Connector.Connect(IConnectionInfo connectionInfo)
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.CreateAndConnectSession()
at Renci.SshNet.BaseClient.Connect()
at Debug.Program.Main(String[] args) in C:\DEV\ruche\Debug\Program.cs:line 17
With FileZilla everything works with the sames parameters. Don't know what i'm missing....
Here is my code sample :
public SftpClient GetClient()
{
if (string.IsNullOrEmpty(Proxy_Adresse) == false)
{
ConnectionInfo lInfos = new ConnectionInfo(Adresse, //My SFTP adresse
Port, // 22
Username, //My SFTP User
ProxyTypes.Socks5,
Proxy_Adresse,
Proxy_Port, //1080
Proxy_Username, //empty in my case
Proxy_Password, //empty in my case
new PasswordAuthenticationMethod(Username, Password)); //My SFTP User / Password
return new SftpClient(lInfos);
}
else
{
return new SftpClient(Adresse, Port, Username, Password);
}
}
using (var lClient = lSFTP.GetClient())
{
lClient.Connect();
Console.WriteLine("OK");
}