Advertisement
Guest User

Untitled

a guest
May 21st, 2016
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using Renci.SshNet;
  11.  
  12. namespace simplest_ssh_shell_bare_text
  13. {
  14. public partial class Form1 : Form
  15. {
  16. /* Reserving Global Objects */
  17. SshClient SSHServerConnection;
  18. ShellStream SSHStream;
  19. /* Creating Global variables for the Global Objects */
  20. private string sIP, sUSERNAME, sPASSWORD;
  21. private int iIPORT;
  22.  
  23. private void buttonDISCONNECT_Click(object sender, EventArgs e)
  24. {
  25. try
  26. {
  27. /* Calling Disconnect Method from SshClient namespace */
  28. SSHServerConnection.Disconnect();
  29. MessageBox.Show("Disconnect from the Server sucessful");
  30. }
  31. catch
  32. {
  33. MessageBox.Show("COULD NOT DETERMISH THE CONNECTION");
  34. }
  35. }
  36.  
  37. public Form1()
  38. {
  39. InitializeComponent();
  40. }
  41.  
  42. private void groupBox1_Enter(object sender, EventArgs e)
  43. {
  44.  
  45. }
  46.  
  47. private void buttonCONNECT_Click(object sender, EventArgs e)
  48. {
  49. try
  50. {
  51. /* Collection connection data from the Textboxes */
  52.  
  53. sIP = textBoxIP.Text;
  54. iIPORT = Convert.ToInt32(textBoxPORT.Text);
  55. sUSERNAME = textBoxUSER.Text;
  56. sPASSWORD = textBoxPASSWORD.Text;
  57.  
  58. /* FILL THE GLOBAL OBJECT WITH DATA */
  59.  
  60. SSHServerConnection = new SshClient(sIP, iIPORT, sUSERNAME, sPASSWORD);
  61.  
  62. /* LET THE OBJECT USE HIS CONNECT METHOD object.method */
  63.  
  64. SSHServerConnection.Connect();
  65.  
  66. /* FILL THE GLOBAL STREAM OBJECT WHICH LAYS UNDER THE THE SSHCLIENT OBJECT, WITH DATA */
  67.  
  68. SSHStream = SSHServerConnection.CreateShellStream("Streamy", 80, 24, 800, 600, 1024);
  69. MessageBox.Show("Server connection etablished");
  70.  
  71. }
  72. catch
  73. {
  74.  
  75. MessageBox.Show("COULD NOT CONNECT TO THE SERVER");
  76.  
  77. }
  78. }
  79.  
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement