Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: How can I enable authentication fowarding

$
0
0
Found the answer posted by da_rinkes in the topic RunCommand() doesn't work? .

Port forwarding is the key. The pseudo code example provided by da_rinkes (reposted below) worked almost verbatim.
 using (var client = new SshClient("192.168.1.10", "root", "magic!0n3"))
            {
                client.Connect();

                // foward remote ssh port to your local machine
                ForwardedPortLocal forwarding =  new ForwardedPortLocal("127.0.0.1", "12345", "192.168.1.11", "22");
                client.AddForwardedPort(forwarding);
                forwarding.Start();

                // connect to it
                SshClient forwardedSsh = new SshClient("127.0.0.1", 12345, "root", "password/key");
                forwardedSsh.Connect();

                // run your commands
                MessageBox.Show(forwardedSsh.RunCommand("ls").Result);
            }

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>