using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Tamir.Streams; using Tamir.SharpSsh; namespace rapidShell { public partial class Form1 : Form { string host, username, password; string nl = Environment.NewLine; public Form1() { InitializeComponent(); } private void tbpassword_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { SshConnect(); } } private void tbhost_TextChanged(object sender, EventArgs e) { host = tbhost.Text; } private void tbusername_TextChanged(object sender, EventArgs e) { username = tbusername.Text; } private void tbpassword_TextChanged(object sender, EventArgs e) { password = tbpassword.Text; } private void textBox9_KeyDown(object sender, KeyEventArgs e) { if(e.KeyCode == Keys.Enter) { SshConnect(); } } public void SshConnect() { try { tbStream.Text = " -Connecting.." + nl + nl; SshStream ssh = new SshStream(host, username, password); // <-----I need to access this 'ssh.write' from a seperate method to run commands tbStream.Text += "\tOk (" + ssh.Cipher + "/" + ssh.Mac + ")" + nl; tbStream.Text += "\tServer version=" + ssh.ServerVersion + nl; tbStream.Text += "\tClient version=" + ssh.ClientVersion + nl + nl; tbStream.Text += "\tUse the 'exit' command to disconnect" + nl + nl; ssh.Prompt = ">"; ssh.RemoveTerminalEmulationCharacters = false; tbStream.Text += ssh.ReadResponse(); } catch (Exception ex) { MessageBox.Show(ex.Message, "RapidSsh - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
ssh
try...catch
SshStream
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)