Hi Sebastian, Oleg,
I see that you say that you had success with dynamic ports and I wondered if you could provide some more details as I am struggling with this.
I have set up an SSH client with dynamic port forwarding on 1080 (see simple code example at the end).
The client connection and port forwarding is successful (port and client IsConnected both true).
Also the sshd server auth.log (Debian Linux) shows that the session was opened OK as follows:
Any help really appreciated - hopefully it's something simple I'm doing wrong!! Thanks.
I see that you say that you had success with dynamic ports and I wondered if you could provide some more details as I am struggling with this.
I have set up an SSH client with dynamic port forwarding on 1080 (see simple code example at the end).
The client connection and port forwarding is successful (port and client IsConnected both true).
Also the sshd server auth.log (Debian Linux) shows that the session was opened OK as follows:
Apr 30 15:09:33 myserver sshd[3297]: Accepted publickey for pi from 83.99.144.145 port 51313 ssh2
Apr 30 15:09:33 myserver sshd[3297]: pam_unix(sshd:session): session opened for user pi by (uid=0)
So far so good. However when I try to use the forwarded port as a SOCKS5 proxy from Firefox the request times out. I have tried the same SSH setup with PuTTY and this works fine.Any help really appreciated - hopefully it's something simple I'm doing wrong!! Thanks.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Renci.SshNet;
namespace SSHTest
{
class Program
{
static void Main(string[] args)
{
System.Console.WriteLine("SSH Test");
string keyfile = "C:\\PI_01_sshnet.ppk";
string host = "81.82.183.175";
string username = "test";
int port = 22;
string pword = "";
System.Console.WriteLine("Enter key file pass code:");
ConsoleColor oldFore = Console.ForegroundColor;
Console.ForegroundColor = Console.BackgroundColor;
pword = System.Console.ReadLine();
Console.ForegroundColor = oldFore;
var connectionInfo = new PrivateKeyConnectionInfo(host, port, username, new PrivateKeyFile(keyfile, pword));
using (var myclient = new SshClient(connectionInfo))
{
myclient.Connect();
if (myclient.IsConnected)
System.Console.WriteLine("Client connected");
else
System.Console.WriteLine("Connection error");
var dynamicPort = new ForwardedPortDynamic(1080);
myclient.AddForwardedPort(dynamicPort);
dynamicPort.Start();
if (dynamicPort.IsStarted)
{
System.Console.WriteLine("Port forwarding started OK");
}
else
{
System.Console.WriteLine("Port forwarding not started");
}
System.Console.WriteLine("Press enter to exit");
System.Console.ReadLine();
myclient.Disconnect();
}
}
}