Skip to content

How to connection cisco router or firewall #379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
haopxt opened this issue Jan 26, 2018 · 3 comments
Closed

How to connection cisco router or firewall #379

haopxt opened this issue Jan 26, 2018 · 3 comments
Milestone

Comments

@haopxt
Copy link

haopxt commented Jan 26, 2018

I use SSH.NET successful connection to my linux server,but dot not connection to cisco router or firewall,can you give me a example for cisco router,thank you!

@haopxt
Copy link
Author

haopxt commented Jan 26, 2018

using System;
using Renci.SshNet;
using System.Text;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
//string ip = "192.168.35.201";
//string userName = "root";
//string userPassword = "123456";
//string command = "ifconfig";
//ssh_conn_Linux(ip, userName, userPassword, command);

        string ip = "192.168.38.254";
        string userName = "cisco";
        string userPassword = "cisco";
        string enPassword = "cisco123";
        string command = "show run | in route";
        ssh_conn_Network(ip, userName, userPassword, enPassword, command);

        Console.ReadKey();
    }
    //Connection Success and response
    public static void ssh_conn_Linux(string ip, string userName, string userPassword, string command)
    {
        StringBuilder result = new StringBuilder();
        var client = new SshClient(ip, userName, userPassword);
        client.Connect();
        result.Append(client.RunCommand(command).Execute() + "\r\n");
        Console.WriteLine(result);
        client.Disconnect();
    }
    //Connection Success,but dot not response
    public static void ssh_conn_Network(string ip, string userName, string userPassword, string enPassword, string command)
    {
        StringBuilder result = new StringBuilder();
        var client = new SshClient(ip, userName, userPassword);
        client.Connect();
        if (client.IsConnected)
        {
            Console.WriteLine("Conn");
            result.Append(client.RunCommand("en").Execute() + "\r\n");
            result.Append(client.RunCommand(enPassword).Execute() + "\r\n");
            result.Append(client.RunCommand(command).Execute() + "\r\n");
            Console.WriteLine(result);
        }
        else
        {
            Console.WriteLine("Dot not conn");
        }
        client.Disconnect();
    }
}

}

@WojciechNagorski
Copy link
Collaborator

It's done in #1274

@WojciechNagorski WojciechNagorski added this to the 2023.0.1 milestone Dec 21, 2023
@WojciechNagorski
Copy link
Collaborator

The 2023.0.1 version has been released to Nuget: https://www.nuget.org/packages/SSH.NET/2023.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants