05-19-2020 08:55 AM
Hi,
Not sure if it's the right place to ask, but I'm trying to establish an SSH connection programmatically and my session keep timing out.
I want to create a program to wrap the CLI commands of the Cisco switch (SG250-26) to make it easier to use for our users.
In the Cisco switch, I checked the SSH Service checkbox to enable the ssh service.
I am able to establish an ssh connection by using the command line "ssh [ip address]" but I can't wrap the CLI commands this way.
When I try to connect with an SSH client using the hostname, username and password (tried 3 differents library already), the ssh session keeps timing out.
Is there something I need to activate in the Cisco parameters to make this work out?
Any suggestion would be great.
Thanks,
Ktmachinex
05-19-2020 05:09 PM
Personally i do not belive these switches has any API programmability
what kind of test you using, post some example to understand, before we go further are you able to SSH in to device ?
05-20-2020 05:57 AM
Requirements :
- Visual Studio 2019
- https://github.com/sshnet/SSH.NET
Steps :
string host = "192.168.1.254"; int port = 22; string username = "cisco"; string password = "cisco"; try { using (var client = new SshClient(host, port, username, password)) { // Throws an exception on the following line client.Connect(); if (client.IsConnected) { //Do something } } } catch (Exception ex) { //Session operation has timed out Debug.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace.ToString()); }
Each time I try to execute the Connect method, the session keep timing out.
When I try to use the same code to connect to a Linux server instead, it succeed.
Any suggestions?
I can send the "ssh [ip address]" command just fine, but I can't achieve my goal this way which is to wrap the cisco CLI commands into an "easier" to use program.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide