Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- telnet localhost 21000
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Renci.SshNet;
- using MinimalisticTelnet;
- namespace Ssh_Net
- {
- class Program
- {
- static void Main(string[] args)
- {
- String host = "54.88.81.210";
- String username = "root";
- String password = "abcd1234";
- int port = 22;
- ForwardedPortDynamic tunnelPort;
- // Setup SSH with Credentials
- ConnectionInfo ConnNfo = new ConnectionInfo(host, port, username,
- new AuthenticationMethod[] {
- /* Password based authentication */
- new PasswordAuthenticationMethod(username, password)
- }
- );
- // Instantly execute a shell command
- using (var sshclient = new SshClient(ConnNfo))
- {
- sshclient.Connect();
- Console.WriteLine("Connecting");
- if (sshclient.IsConnected)
- {
- try
- {
- Console.WriteLine(sshclient.RunCommand("telnet localhost 21000").Execute());
- }
- catch (Exception e)
- {
- Console.Write(e.ToString());
- }
- }
- Console.ReadLine();
- sshclient.Disconnect();
- }
- }
- }
- }
- sshMaster = new SshClient(host, sshUserSSL, sshPwdSSL);
- sshMaster.Connect();
- ShellStream shell = sshMaster.CreateShellStream("master", 80, 24, 800, 600, 1024);
- shell.WriteLine(" telnet localhost 21000");
- shell.WriteLine(USERNAME);
- shell.WriteLine(PASSWORD);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement