Tryout GIT with Testing code

This commit is contained in:
An Dao
2025-12-12 12:40:19 -08:00
commit 392f73ee25
23 changed files with 2282 additions and 0 deletions

6
SSH_Test/App.config Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>

182
SSH_Test/FormConfiguration.Designer.cs generated Normal file
View File

@@ -0,0 +1,182 @@
namespace SSH_Test
{
partial class FormConfiguration
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.labelIP = new System.Windows.Forms.Label();
this.textBoxSftpIP = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.textBoxSftpPassword = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.textBoxSftpUsername = new System.Windows.Forms.TextBox();
this.buttonOK = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label5 = new System.Windows.Forms.Label();
this.textBoxTftpIP = new System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// labelIP
//
this.labelIP.AutoSize = true;
this.labelIP.Location = new System.Drawing.Point(20, 28);
this.labelIP.Name = "labelIP";
this.labelIP.Size = new System.Drawing.Size(17, 13);
this.labelIP.TabIndex = 0;
this.labelIP.Text = "IP";
this.labelIP.Click += new System.EventHandler(this.label1_Click);
//
// textBoxSftpIP
//
this.textBoxSftpIP.Location = new System.Drawing.Point(55, 25);
this.textBoxSftpIP.Name = "textBoxSftpIP";
this.textBoxSftpIP.Size = new System.Drawing.Size(214, 20);
this.textBoxSftpIP.TabIndex = 1;
this.textBoxSftpIP.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.textBoxSftpPassword);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.textBoxSftpUsername);
this.groupBox1.Controls.Add(this.labelIP);
this.groupBox1.Controls.Add(this.textBoxSftpIP);
this.groupBox1.Location = new System.Drawing.Point(12, 71);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(278, 118);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Sftp";
this.groupBox1.Enter += new System.EventHandler(this.groupBox1_Enter);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(20, 80);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 13);
this.label2.TabIndex = 4;
this.label2.Text = "Password";
this.label2.Click += new System.EventHandler(this.label2_Click);
//
// textBoxSftpPassword
//
this.textBoxSftpPassword.Location = new System.Drawing.Point(83, 77);
this.textBoxSftpPassword.Name = "textBoxSftpPassword";
this.textBoxSftpPassword.Size = new System.Drawing.Size(186, 20);
this.textBoxSftpPassword.TabIndex = 5;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(20, 54);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(57, 13);
this.label1.TabIndex = 2;
this.label1.Text = "UserName";
//
// textBoxSftpUsername
//
this.textBoxSftpUsername.Location = new System.Drawing.Point(83, 51);
this.textBoxSftpUsername.Name = "textBoxSftpUsername";
this.textBoxSftpUsername.Size = new System.Drawing.Size(186, 20);
this.textBoxSftpUsername.TabIndex = 3;
//
// buttonOK
//
this.buttonOK.Location = new System.Drawing.Point(55, 195);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(151, 23);
this.buttonOK.TabIndex = 4;
this.buttonOK.Text = "OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.label5);
this.groupBox2.Controls.Add(this.textBoxTftpIP);
this.groupBox2.Location = new System.Drawing.Point(12, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(278, 53);
this.groupBox2.TabIndex = 6;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Tftp";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(20, 28);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(17, 13);
this.label5.TabIndex = 0;
this.label5.Text = "IP";
//
// textBoxTftpIP
//
this.textBoxTftpIP.Location = new System.Drawing.Point(55, 25);
this.textBoxTftpIP.Name = "textBoxTftpIP";
this.textBoxTftpIP.Size = new System.Drawing.Size(214, 20);
this.textBoxTftpIP.TabIndex = 1;
//
// FormConfiguration
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(297, 228);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.groupBox1);
this.Name = "FormConfiguration";
this.Text = "FormConfiguration";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Label labelIP;
private System.Windows.Forms.TextBox textBoxSftpIP;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBoxSftpPassword;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBoxSftpUsername;
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBoxTftpIP;
}
}

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SSH_Test
{
public partial class FormConfiguration : Form
{
public string Tftp_IP { get; set; }
public string Sftp_IP { get; set; }
public string Sftp_Username { get; set; }
public string Sftp_Password { get; set; }
public FormConfiguration(string tftp_IP, string sftpIP, string sftp_Username, string sftp_Password)
{
InitializeComponent();
this.textBoxTftpIP.Text = Tftp_IP = tftp_IP;
this.textBoxSftpIP.Text = Sftp_IP = sftpIP;
this.textBoxSftpUsername.Text = Sftp_Username = sftp_Username;
this.textBoxSftpPassword.Text = Sftp_Password = sftp_Password;
this.Update();
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void buttonOK_Click(object sender, EventArgs e)
{
Tftp_IP = textBoxTftpIP.Text;
Sftp_IP = textBoxSftpIP.Text;
Sftp_Username = textBoxSftpUsername.Text;
Sftp_Password = textBoxSftpPassword.Text;
this.Close();
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

124
SSH_Test/FormCredential.Designer.cs generated Normal file
View File

@@ -0,0 +1,124 @@
namespace SSH_Test
{
partial class FormCredential
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBoxUserName = new System.Windows.Forms.TextBox();
this.textBoxPassword = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOK = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBoxUserName
//
this.textBoxUserName.Location = new System.Drawing.Point(12, 25);
this.textBoxUserName.Name = "textBoxUserName";
this.textBoxUserName.Size = new System.Drawing.Size(176, 20);
this.textBoxUserName.TabIndex = 0;
this.textBoxUserName.WordWrap = false;
this.textBoxUserName.TextChanged += new System.EventHandler(this.textBoxUserName_TextChanged);
//
// textBoxPassword
//
this.textBoxPassword.Location = new System.Drawing.Point(12, 64);
this.textBoxPassword.Name = "textBoxPassword";
this.textBoxPassword.PasswordChar = '*';
this.textBoxPassword.Size = new System.Drawing.Size(176, 20);
this.textBoxPassword.TabIndex = 1;
this.textBoxPassword.TextChanged += new System.EventHandler(this.textBoxPassword_TextChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(63, 13);
this.label1.TabIndex = 2;
this.label1.Text = "User Name:";
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 13);
this.label2.TabIndex = 3;
this.label2.Text = "Password";
this.label2.Click += new System.EventHandler(this.label2_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(12, 90);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 4;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonOK
//
this.buttonOK.Location = new System.Drawing.Point(111, 90);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 5;
this.buttonOK.Text = "OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
//
// FormCredential
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(198, 119);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBoxPassword);
this.Controls.Add(this.textBoxUserName);
this.Name = "FormCredential";
this.Text = "Credential";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBoxUserName;
private System.Windows.Forms.TextBox textBoxPassword;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonOK;
}
}

View File

@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SSH_Test
{
public partial class FormCredential : Form
{
public string Username { get; set; }
public string Password { get; set; }
public FormCredential(string username, string password)
{
InitializeComponent();
textBoxUserName.Text = Username=username;
textBoxUserName.Update();
textBoxPassword.Text = Password=password;
textBoxPassword.Update();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void textBoxUserName_TextChanged(object sender, EventArgs e)
{
textBoxUserName.Focus();
Username = textBoxUserName.Text;
}
private void textBoxPassword_TextChanged(object sender, EventArgs e)
{
textBoxPassword.Focus();
Password = textBoxPassword.Text;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
Username = "";
Password = "";
this.Close();
}
private void buttonOK_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

80
SSH_Test/FormProfile.Designer.cs generated Normal file
View File

@@ -0,0 +1,80 @@
namespace SSH_Test
{
partial class FormProfile
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.comboBoxProfile = new System.Windows.Forms.ComboBox();
this.bOK = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// comboBoxProfile
//
this.comboBoxProfile.FormattingEnabled = true;
this.comboBoxProfile.Items.AddRange(new object[] {
"Cisco_Switch",
"Cisco_Switch_Tftp",
"Cisco_Switch_Sftp",
"Cisco_Switch_Tftp_Startup",
"Cisco_Router",
"Cisco-Firewall"});
this.comboBoxProfile.Location = new System.Drawing.Point(12, 12);
this.comboBoxProfile.Name = "comboBoxProfile";
this.comboBoxProfile.Size = new System.Drawing.Size(121, 21);
this.comboBoxProfile.TabIndex = 0;
this.comboBoxProfile.TextChanged += new System.EventHandler(this.comboBoxProfile_TextChanged);
//
// bOK
//
this.bOK.Location = new System.Drawing.Point(13, 56);
this.bOK.Name = "bOK";
this.bOK.Size = new System.Drawing.Size(120, 23);
this.bOK.TabIndex = 1;
this.bOK.Text = "OK";
this.bOK.UseCompatibleTextRendering = true;
this.bOK.UseVisualStyleBackColor = true;
this.bOK.Click += new System.EventHandler(this.bOK_Click);
//
// FormProfile
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(144, 98);
this.Controls.Add(this.bOK);
this.Controls.Add(this.comboBoxProfile);
this.Name = "FormProfile";
this.Text = "Profile";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ComboBox comboBoxProfile;
private System.Windows.Forms.Button bOK;
}
}

48
SSH_Test/FormProfile.cs Normal file
View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace SSH_Test
{
public partial class FormProfile : Form
{
public string sProfile { get; set; }
public FormProfile(string sProfile)
{
InitializeComponent();
this.sProfile = sProfile;
if (sProfile != null) sProfile = "Cisco_Switch";
int index = comboBoxProfile.FindStringExact(sProfile);
// If the item is found, set it as the selected item
if (index != -1)
{
comboBoxProfile.SelectedIndex = index;
}
else
{
comboBoxProfile.SelectedIndex = 0;
}
}
private void bOK_Click(object sender, EventArgs e)
{
this.Close();
}
private void comboBoxProfile_TextChanged(object sender, EventArgs e)
{
Console.WriteLine("Profile changes to: {0}", comboBoxProfile.SelectedItem.ToString());
sProfile = comboBoxProfile.SelectedItem.ToString();
}
}
}

120
SSH_Test/FormProfile.resx Normal file
View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

22
SSH_Test/Program.cs Normal file
View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SSH_Test
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new TastList());
}
}
}

View File

@@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SSH_Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SSH_Test")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("73ded4cd-b2b1-491e-87b7-bc1f11759c53")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SSH_Test.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SSH_Test.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

30
SSH_Test/Properties/Settings.Designer.cs generated Normal file
View File

@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SSH_Test.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

178
SSH_Test/SSH_Test.csproj Normal file
View File

@@ -0,0 +1,178 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{73DED4CD-B2B1-491E-87B7-BC1F11759C53}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>SSH_Test</RootNamespace>
<AssemblyName>SSH_Test</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
<HintPath>packages\BouncyCastle.Cryptography.2.6.2\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.2\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.3, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Extensions.Logging.Abstractions.8.0.3\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Renci.SshNet, Version=2025.1.0.1, Culture=neutral, PublicKeyToken=1cee9f8bde3db106, processorArchitecture=MSIL">
<HintPath>packages\SSH.NET.2025.1.0\lib\net462\Renci.SshNet.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Formats.Asn1, Version=8.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Formats.Asn1.8.0.2\lib\net462\System.Formats.Asn1.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FormConfiguration.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormConfiguration.Designer.cs">
<DependentUpon>FormConfiguration.cs</DependentUpon>
</Compile>
<Compile Include="FormCredential.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormCredential.Designer.cs">
<DependentUpon>FormCredential.cs</DependentUpon>
</Compile>
<Compile Include="FormProfile.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormProfile.Designer.cs">
<DependentUpon>FormProfile.cs</DependentUpon>
</Compile>
<Compile Include="TastList.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="TastList.Designer.cs">
<DependentUpon>TastList.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FormConfiguration.resx">
<DependentUpon>FormConfiguration.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormCredential.resx">
<DependentUpon>FormCredential.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormProfile.resx">
<DependentUpon>FormProfile.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="TastList.resx">
<DependentUpon>TastList.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>

3
SSH_Test/SSH_Test.slnx Normal file
View File

@@ -0,0 +1,3 @@
<Solution>
<Project Path="SSH_Test.csproj" Id="73ded4cd-b2b1-491e-87b7-bc1f11759c53" />
</Solution>

197
SSH_Test/TastList.Designer.cs generated Normal file
View File

@@ -0,0 +1,197 @@
namespace SSH_Test
{
partial class TastList
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.bRunAll = new System.Windows.Forms.Button();
this.dataGridViewTask = new System.Windows.Forms.DataGridView();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonLoad = new System.Windows.Forms.Button();
this.TaskNum = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.TaskDescription = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.TaskDevice = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.TaskIp = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Port = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Run = new System.Windows.Forms.DataGridViewButtonColumn();
this.Credential = new System.Windows.Forms.DataGridViewButtonColumn();
this.Profile = new System.Windows.Forms.DataGridViewButtonColumn();
this.buttonConf = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridViewTask)).BeginInit();
this.SuspendLayout();
//
// bRunAll
//
this.bRunAll.Location = new System.Drawing.Point(782, 9);
this.bRunAll.Name = "bRunAll";
this.bRunAll.Size = new System.Drawing.Size(92, 23);
this.bRunAll.TabIndex = 1;
this.bRunAll.Text = "Run All";
this.bRunAll.UseVisualStyleBackColor = true;
this.bRunAll.Click += new System.EventHandler(this.bRunAll_Click);
//
// dataGridViewTask
//
this.dataGridViewTask.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridViewTask.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.TaskNum,
this.TaskDescription,
this.TaskDevice,
this.TaskIp,
this.Port,
this.Run,
this.Credential,
this.Profile});
this.dataGridViewTask.Location = new System.Drawing.Point(8, 41);
this.dataGridViewTask.Name = "dataGridViewTask";
this.dataGridViewTask.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
this.dataGridViewTask.Size = new System.Drawing.Size(1043, 397);
this.dataGridViewTask.TabIndex = 2;
this.dataGridViewTask.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridViewTask_CellContentClick);
this.dataGridViewTask.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridViewTask_CellEndEdit);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(114, 9);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(96, 23);
this.buttonSave.TabIndex = 3;
this.buttonSave.Text = "Save Task List";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
// buttonLoad
//
this.buttonLoad.Location = new System.Drawing.Point(12, 9);
this.buttonLoad.Name = "buttonLoad";
this.buttonLoad.Size = new System.Drawing.Size(96, 23);
this.buttonLoad.TabIndex = 4;
this.buttonLoad.Text = "Load Tasklisk";
this.buttonLoad.UseVisualStyleBackColor = true;
this.buttonLoad.Click += new System.EventHandler(this.buttonLoad_Click);
//
// TaskNum
//
this.TaskNum.HeaderText = "Task #";
this.TaskNum.Name = "TaskNum";
//
// TaskDescription
//
this.TaskDescription.HeaderText = "Description";
this.TaskDescription.MinimumWidth = 50;
this.TaskDescription.Name = "TaskDescription";
this.TaskDescription.Width = 400;
//
// TaskDevice
//
this.TaskDevice.HeaderText = "Device";
this.TaskDevice.Name = "TaskDevice";
//
// TaskIp
//
this.TaskIp.HeaderText = "IP";
this.TaskIp.Name = "TaskIp";
this.TaskIp.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.TaskIp.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.TaskIp.ToolTipText = "IP address";
//
// Port
//
this.Port.HeaderText = "Port";
this.Port.Name = "Port";
this.Port.ToolTipText = "Port SSH=22";
this.Port.Width = 50;
//
// Run
//
this.Run.HeaderText = "Run";
this.Run.Name = "Run";
this.Run.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.Run.Text = "Run";
this.Run.Width = 50;
//
// Credential
//
this.Credential.HeaderText = "Credential";
this.Credential.Name = "Credential";
this.Credential.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.Credential.Width = 80;
//
// Profile
//
this.Profile.HeaderText = "Profile";
this.Profile.Name = "Profile";
this.Profile.ReadOnly = true;
this.Profile.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.Profile.Width = 120;
//
// buttonConf
//
this.buttonConf.Location = new System.Drawing.Point(216, 9);
this.buttonConf.Name = "buttonConf";
this.buttonConf.Size = new System.Drawing.Size(96, 23);
this.buttonConf.TabIndex = 5;
this.buttonConf.Text = "Configuration";
this.buttonConf.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
this.buttonConf.UseVisualStyleBackColor = true;
this.buttonConf.Click += new System.EventHandler(this.buttonConf_Click);
//
// TastList
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1055, 450);
this.Controls.Add(this.buttonConf);
this.Controls.Add(this.buttonLoad);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.dataGridViewTask);
this.Controls.Add(this.bRunAll);
this.Name = "TastList";
this.Text = "Task List";
this.Load += new System.EventHandler(this.fSSHTest_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridViewTask)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button bRunAll;
private System.Windows.Forms.DataGridView dataGridViewTask;
private System.Windows.Forms.Button buttonSave;
private System.Windows.Forms.Button buttonLoad;
private System.Windows.Forms.DataGridViewTextBoxColumn TaskNum;
private System.Windows.Forms.DataGridViewTextBoxColumn TaskDescription;
private System.Windows.Forms.DataGridViewTextBoxColumn TaskDevice;
private System.Windows.Forms.DataGridViewTextBoxColumn TaskIp;
private System.Windows.Forms.DataGridViewTextBoxColumn Port;
private System.Windows.Forms.DataGridViewButtonColumn Run;
private System.Windows.Forms.DataGridViewButtonColumn Credential;
private System.Windows.Forms.DataGridViewButtonColumn Profile;
private System.Windows.Forms.Button buttonConf;
}
}

528
SSH_Test/TastList.cs Normal file
View File

@@ -0,0 +1,528 @@
using Renci.SshNet;
using Renci.SshNet.Common;
using System;
using System.Threading;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace SSH_Test
{
public partial class TastList : Form
{
public List<cTask> Tasks = new List<cTask>();
public cFtpInfo ftpInfo = new cFtpInfo("","","","","","");
public TastList()
{
InitializeComponent();
}
private void fSSHTest_Load(object sender, EventArgs e)
{
}
private void bRunAll_Click(object sender, EventArgs e)
{
}
private void dataGridViewTask_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
string host = "";
string username = "";
string password = "";
string profile = "";
try
{
var currentTask = Tasks[e.RowIndex];
host = currentTask.sTaskIP.ToString();
username = currentTask.sUsername.ToString();
password = currentTask.sPassword.ToString();
switch (e.ColumnIndex)
{
case 5:
profile = currentTask.sProfile.ToString();
cHostInfo hostInfo = new cHostInfo();
hostInfo.host = host;
hostInfo.username = username;
hostInfo.password = password;
hostInfo.device = currentTask.sTaskDevice.ToString();
switch (profile)
{
case "Cisco_Switch":
Thread thread1 = new Thread(new ParameterizedThreadStart(fSSHCisco));
thread1.Start(hostInfo);
break;
case "Cisco_Switch_Tftp":
hostInfo.SftpIP = ftpInfo.sTftpIP;
Thread thread2 = new Thread(new ParameterizedThreadStart(fSSHCisco_Tftp));
thread2.Start(hostInfo);
break;
case "Cisco_Switch_Tftp_Startup":
hostInfo.SftpIP = ftpInfo.sTftpIP;
hostInfo.SftpPassword = ftpInfo.sTftpPassword;
hostInfo.SftpUsername = ftpInfo.sTftpUsername;
Thread thread3 = new Thread(new ParameterizedThreadStart(fSSHCisco_Tftp_Startup));
thread3.Start(hostInfo);
break;
default:
break;
}
break;
case 6: //call Credential
FormCredential formCredential = new FormCredential(username, password);
formCredential.ShowDialog();
if ((formCredential.Username != "") && (formCredential.Username != username))
username = currentTask.sUsername = formCredential.Username;
if ((formCredential.Password != "") && formCredential.Password != password)
password = currentTask.sPassword = formCredential.Password;
break;
case 7: //call Profile
FormProfile formProfile = new FormProfile(profile);
formProfile.ShowDialog();
profile = currentTask.sProfile = formProfile.sProfile;
dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = profile;
break;
default:
break;
}
}
catch ( Exception ex)
{
}
}
private void dataGridViewTask_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex != 5)
{
if (Tasks.Count < (e.RowIndex + 1))
{
Tasks.Add(new cTask(e.RowIndex + 1, "", "", "", "", "", "",""));
}
switch (e.ColumnIndex)
{
case 0:
Tasks[e.RowIndex].iTaskNum = e.RowIndex + 1;
break;
case 1:
Tasks[e.RowIndex].sTaskDescription = (string)dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
break;
case 2:
Tasks[e.RowIndex].sTaskDevice = (string)dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
break;
case 3:
Tasks[e.RowIndex].sTaskIP = (string)dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
break;
case 4:
Tasks[e.RowIndex].uTaskPort = (string)dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
break;
case 5:
break;
case 7: // Profile
Tasks[e.RowIndex].sProfile = (string)dataGridViewTask.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
break;
default:
break;
}
}
}
private void buttonSave_Click(object sender, EventArgs e)
{
if (Tasks.Count > 1)
{
using (Stream stream = File.Open("tasklist.dat", FileMode.Create))
{
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
binaryFormatter.Serialize(stream, Tasks);
}
using (Stream stream = File.Open("ftpInfo.dat", FileMode.Create))
{
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
binaryFormatter.Serialize(stream, ftpInfo);
}
}
}
private void buttonLoad_Click(object sender, EventArgs e)
{
using (Stream stream = File.Open("tasklist.dat", FileMode.Open))
{
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
Tasks = (List<cTask>)binaryFormatter.Deserialize(stream);
}
using (Stream stream = File.Open("ftpInfo.dat", FileMode.Open))
{
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
ftpInfo = (cFtpInfo)binaryFormatter.Deserialize(stream);
}
//clear TaskList
dataGridViewTask.Rows.Clear();
foreach (var task in Tasks)
{
DataGridViewRow row = (DataGridViewRow)dataGridViewTask.Rows[0].Clone();
row.Cells[0].Value = task.iTaskNum;
row.Cells[1].Value = task.sTaskDescription;
row.Cells[2].Value = task.sTaskDevice;
row.Cells[3].Value = task.sTaskIP;
row.Cells[4].Value = task.uTaskPort;
row.Cells[7].Value = task.sProfile;
dataGridViewTask.Rows.Add(row);
}
}
public class cHostInfo
{
public string device { get; set; }
public string host { get; set; }
public string username { get; set; }
public string password { get; set; }
public string SftpIP { get; set; }
public string SftpUsername { get; set; }
public string SftpPassword { get; set; }
}
public void fSSHCisco(object data)
{
cHostInfo hostinfo = (cHostInfo)data;
var client = new SshClient(hostinfo.host, hostinfo.username, hostinfo.password);
Console.WriteLine("From SSH_Test: Establishing a connection");
client.Connect();
Console.WriteLine(client.ConnectionInfo.ServerVersion);
string host = hostinfo.host;
string device = hostinfo.device;
string username = hostinfo.username;
string password = hostinfo.password;
if (client.IsConnected)
{
uint i = 0;
var shellStream = client.CreateShellStream("xterm", 80, 24, 800, 600, 1024);
var output = "";
var result = "";
//Cisco SG300
//wait for "User Name:"
output = shellStream.Expect(new Regex(@"Name:|name:"));
Console.WriteLine("From SSH_Test {0}: {1}", i++, output);
//send username
shellStream.WriteLine(username);
//wait for "Password:"
output = shellStream.Expect(new Regex(@"word:"));
Console.WriteLine("From SSH_Test {0}: {1}", i++, output);
//send password
shellStream.WriteLine(password);
//wait for "Prompt:"
output = shellStream.Expect(new Regex(@"#"));
Console.WriteLine("From SSH_Test {0}: {1}", i++, output);
output = "";
//send sh run
shellStream.WriteLine("sh run");
//wait "<return>" to send "space" and loop until get prompt
while (!Regex.IsMatch(output, "#"))
{
output = shellStream.Expect(new Regex(@"More|<return>|#"));
shellStream.WriteLine(" ");
string[] lines = output.Split('\n');
var output1 = "";
for (int ii = 0; ii < (lines.Length - 1); ii++)
output1 += lines[ii];
Console.WriteLine(output1);
result += output1;
}
//write to file
string datetime = DateTime.Now.ToString().Replace(":", "");
datetime = datetime.Replace(" ", "_");
// string filePath = string.Format("{0}_{1}.txt", currentTask.sTaskDevice, datetime.Replace("-", ""));
string filePath = string.Format("{0}_{1}.txt", device, datetime.Replace("-", ""));
try
{
// Write the string to the file, overwriting existing content if the file exists
File.WriteAllText(filePath, result);
System.Console.WriteLine($"Successfully wrote to {filePath}");
}
catch (IOException ex)
{
System.Console.WriteLine($"An error occurred while writing to the file: {ex.Message}");
}
}
client.Disconnect();
Console.WriteLine("From SSH_Test: Disconnected");
}
public void fSSHCisco_Tftp(object data)
{
cHostInfo hostinfo = (cHostInfo)data;
var client = new SshClient(hostinfo.host, hostinfo.username, hostinfo.password);
Console.WriteLine("From SSH_Test: Establishing a connection");
client.Connect();
Console.WriteLine(client.ConnectionInfo.ServerVersion);
string host = hostinfo.host;
string device = hostinfo.device;
string username = hostinfo.username;
string password = hostinfo.password;
string sftpIp = hostinfo.SftpIP;
string sftpUsername = hostinfo.SftpUsername;
string sftpPassword = hostinfo.SftpPassword;
if (client.IsConnected)
{
uint i = 0;
var shellStream = client.CreateShellStream("xterm", 80, 24, 800, 600, 1024);
var output = "";
var result = "";
//Cisco SG300
//wait for "User Name:"
output = shellStream.Expect(new Regex(@"Name:|name:"));
Console.WriteLine("From SSH_Test {0}: {1}", i++, output);
//send username
shellStream.WriteLine(username);
//wait for "Password:"
output = shellStream.Expect(new Regex(@"word:"));
Console.WriteLine("From SSH_Test {0}: {1}", i++, output);
//send password
shellStream.WriteLine(password);
//wait for "Prompt:"
output = shellStream.Expect(new Regex(@"#"));
Console.WriteLine("From SSH_Test {0}: {1}", i++, output);
output = "";
//send enable
// shellStream.WriteLine("enable");
// wait for "Prompt:"
// output = shellStream.Expect(new Regex(@"#"));
//create filename for running-config
string datetime = DateTime.Now.ToString().Replace(":", "");
datetime = datetime.Replace(" ", "_");
// string filePath = string.Format("{0}_{1}.txt", currentTask.sTaskDevice, datetime.Replace("-", ""));
string filePath = string.Format("{0}_{1}.txt", device, datetime.Replace("-", ""));
string command = string.Format("copy running-config tftp://{0}/{1}", sftpIp, filePath);
Console.WriteLine("From SSH_Test {0}: {1}", i++, command);
shellStream.WriteLine(command);
//send sftp command
//wait "<return>" to send "space" and loop until get prompt
while (!Regex.IsMatch(output, "#"))
{
output = shellStream.Expect(new Regex(@"More|<return>|#"));
shellStream.WriteLine(" ");
string[] lines = output.Split('\n');
var output1 = "";
for (int ii = 0; ii < (lines.Length - 1); ii++)
output1 += lines[ii];
Console.WriteLine(output1);
result += output1;
}
}
client.Disconnect();
Console.WriteLine("From SSH_Test: Disconnected");
}
public void fSSHCisco_Tftp_Startup(object data)
{
cHostInfo hostinfo = (cHostInfo)data;
var client = new SshClient(hostinfo.host, hostinfo.username, hostinfo.password);
Console.WriteLine("From SSH_Test: Establishing a connection");
client.Connect();
Console.WriteLine(client.ConnectionInfo.ServerVersion);
string host = hostinfo.host;
string device = hostinfo.device;
string username = hostinfo.username;
string password = hostinfo.password;
string sftpIp = hostinfo.SftpIP;
string sftpUsername = hostinfo.SftpUsername;
string sftpPassword = hostinfo.SftpPassword;
if (client.IsConnected)
{
uint i = 0;
var shellStream = client.CreateShellStream("xterm", 80, 24, 800, 600, 1024);
var output = "";
var result = "";
//Cisco SG300
//wait for "User Name:"
output = shellStream.Expect(new Regex(@"Name:|name:"));
Console.WriteLine("From SSH_Test {0}: {1}", i++, output);
//send username
shellStream.WriteLine(username);
//wait for "Password:"
output = shellStream.Expect(new Regex(@"word:"));
Console.WriteLine("From SSH_Test {0}: {1}", i++, output);
//send password
shellStream.WriteLine(password);
//wait for "Prompt:"
output = shellStream.Expect(new Regex(@"#"));
Console.WriteLine("From SSH_Test {0}: {1}", i++, output);
output = "";
//send enable
// shellStream.WriteLine("enable");
// wait for "Prompt:"
// output = shellStream.Expect(new Regex(@"#"));
//create filename for running-config
string datetime = DateTime.Now.ToString().Replace(":", "");
datetime = datetime.Replace(" ", "_");
// string filePath = string.Format("{0}_{1}.txt", currentTask.sTaskDevice, datetime.Replace("-", ""));
string filePath = string.Format("{0}_{1}.txt", device, datetime.Replace("-", ""));
string command = string.Format("copy startup-config tftp://{0}/{1}", sftpIp, filePath);
Console.WriteLine("From SSH_Test {0}: {1}", i++, command);
shellStream.WriteLine(command);
//send sftp command
//wait "<return>" to send "space" and loop until get prompt
while (!Regex.IsMatch(output, "#"))
{
output = shellStream.Expect(new Regex(@"More|<return>|#"));
shellStream.WriteLine(" ");
string[] lines = output.Split('\n');
var output1 = "";
for (int ii = 0; ii < (lines.Length - 1); ii++)
output1 += lines[ii];
Console.WriteLine(output1);
result += output1;
}
}
client.Disconnect();
Console.WriteLine("From SSH_Test: Disconnected");
}
private void buttonConf_Click(object sender, EventArgs e)
{
FormConfiguration formConfiguration = new FormConfiguration(ftpInfo.sTftpIP, ftpInfo.sSftpIP, ftpInfo.sSftpUsername, ftpInfo.sSftpPassword);
formConfiguration.ShowDialog();
ftpInfo.sTftpIP = formConfiguration.Tftp_IP;
ftpInfo.sSftpIP = formConfiguration.Sftp_IP;
ftpInfo.sSftpUsername = formConfiguration.Sftp_Username;
ftpInfo.sSftpPassword = formConfiguration.Sftp_Password;
}
[Serializable]
public class cTask
{
public int iTaskNum { get; set; }
public String sTaskDescription { get; set; }
public String sTaskDevice { get; set; }
public String sTaskIP { get; set; }
public String uTaskPort { get; set; }
public String sUsername { get; set; }
public String sPassword { get; set; }
public String sProfile { get; set; }
public cTask(int iTaskNum, string uTaskDescription, string uTaskDevice, string uTaskIP, string uTaskPort, string sUsername, string sPassword, string sProfile)
{
this.iTaskNum = iTaskNum;
this.sTaskDescription = uTaskDescription;
this.sTaskDevice = uTaskDevice;
this.sTaskIP = uTaskIP;
this.uTaskPort = uTaskPort;
this.sUsername = sUsername;
this.sPassword = sPassword;
}
}
[Serializable]
public class cFtpInfo
{
public String sTftpIP { get; set; }
public String sTftpUsername { get; set; }
public String sTftpPassword { get; set; }
public String sSftpIP { get; set; }
public String sSftpUsername { get; set; }
public String sSftpPassword { get; set; }
public cFtpInfo( string TftpIP, string TftpUsername, string TftpPassword, string SftpIP, String SftpUsername, String SftPassword)
{
this.sTftpIP = TftpIP;
this.sTftpUsername = TftpUsername;
this.sTftpPassword = TftpPassword;
this.sSftpIP = SftpIP;
this.sSftpUsername = SftpUsername;
this.sSftpPassword = SftPassword;
}
}
}
}

144
SSH_Test/TastList.resx Normal file
View File

@@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="TaskNum.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TaskDescription.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TaskDevice.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TaskIp.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Port.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Run.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Credential.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Profile.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

15
SSH_Test/packages.config Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BouncyCastle.Cryptography" version="2.6.2" targetFramework="net48" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.2" targetFramework="net48" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="8.0.3" targetFramework="net48" />
<package id="SSH.NET" version="2025.1.0" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Formats.Asn1" version="8.0.2" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
</packages>