Advertisement
Guest User

Untitled

a guest
Sep 11th, 2017
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. telnet localhost 21000
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Renci.SshNet;
  9. using MinimalisticTelnet;
  10.  
  11. namespace Ssh_Net
  12. {
  13. class Program
  14. {
  15.  
  16. static void Main(string[] args)
  17. {
  18. String host = "54.88.81.210";
  19. String username = "root";
  20. String password = "abcd1234";
  21. int port = 22;
  22.  
  23. ForwardedPortDynamic tunnelPort;
  24.  
  25. // Setup SSH with Credentials
  26. ConnectionInfo ConnNfo = new ConnectionInfo(host, port, username,
  27.  
  28. new AuthenticationMethod[] {
  29.  
  30. /* Password based authentication */
  31. new PasswordAuthenticationMethod(username, password)
  32. }
  33. );
  34.  
  35.  
  36. // Instantly execute a shell command
  37.  
  38. using (var sshclient = new SshClient(ConnNfo))
  39. {
  40. sshclient.Connect();
  41. Console.WriteLine("Connecting");
  42.  
  43. if (sshclient.IsConnected)
  44. {
  45. try
  46. {
  47. Console.WriteLine(sshclient.RunCommand("telnet localhost 21000").Execute());
  48.  
  49. }
  50. catch (Exception e)
  51. {
  52. Console.Write(e.ToString());
  53. }
  54. }
  55.  
  56. Console.ReadLine();
  57. sshclient.Disconnect();
  58.  
  59. }
  60.  
  61.  
  62. }
  63.  
  64.  
  65. }
  66. }
  67.  
  68. sshMaster = new SshClient(host, sshUserSSL, sshPwdSSL);
  69. sshMaster.Connect();
  70. ShellStream shell = sshMaster.CreateShellStream("master", 80, 24, 800, 600, 1024);
  71. shell.WriteLine(" telnet localhost 21000");
  72. shell.WriteLine(USERNAME);
  73. shell.WriteLine(PASSWORD);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement