CSharp – SSH into Cisco Router and save running config

I'm learning CSharp and trying to create a simple program that will SSH into a server, login using 'Enable' , followed by password. After run 'show running-config and output that to a textbox. I can successfully connect but then the program hangs. I'm using SSH.NET CSharp Library

private void button1_Click(object sender, EventArgs e) {

 label_status.Text = "Status: Validating Data"; using (var sshClient = new SshClient(ipaddress.Text, username.Text, password.Text)) { sshClient.Connect(); label_status.Text = "Connection Successful"; sshClient.CreateCommand("enable").Execute(); sshClient.CreateCommand(enablepassword.Text).Execute(); var cmd = sshClient.RunCommand("enable"); statusbox.Text = cmd.Result; } 

by luisg707 via /r/csharp

Leave a Reply