Replies: 1 comment
-
var listLineRunConfig = new List();
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Please tell me if it is possible to execute commands sent from C#, let's say by: (of course there may be another solution Renci.SshNet)
`RichTextOut.Document.Blocks.Clear();
var _username = Login.Text.Trim();
var _password = Password.Password.Trim();
var _host = "10.50.50.10";
var _port = 22;
var methods = new List
{
new PasswordAuthenticationMethod(_username, _password),
};
var connectionInfo = new ConnectionInfo(_host, _port, _username, methods.ToArray());
var client = new SshClient(connectionInfo);
client.ConnectionInfo.Timeout = TimeSpan.FromSeconds(30);
client.Connect();
SshCommand runCC = client.CreateCommand("terminal length 0\r\nsh run\r\nexit\r\n");
runCC.CommandTimeout = TimeSpan.FromSeconds(5);
var a = runCC.Execute();
RichTextOut.AppendText(a);
runCC.Dispose();
client.Disconnect();`
This command was supposed to output the entire running-config and exit the ssh connection, but it does not output anything at all.
var a = runCC.Execute(); ->
'Renci.SshNet.Common.SshOperationTimeoutException: "Command
terminal length 0
sh run
exit
has timed out."'
After the connection is completed, Renci.SshNet thinks it is connected, but D-Link does not display in the web interface that it is connected.
I tried to change Encryptions, HmacAlhorithms, but it didn't do anything, it connects with PUTTY and is shown in the web interface, I set the encryption settings similarly, it didn't help.
On cisco hardware, such code can work without problems.
I just need to send commands, not create a real Async connection with D-Link, so please don't suggest that. Thank you in advance for your help!
Beta Was this translation helpful? Give feedback.
All reactions