ssh.net

How do I decrease the ssh.net timeout when my ssh client disconnects from the ssh server?

时间秒杀一切 提交于 2020-07-22 16:59:07
问题 I wrote a small program in C# using ssh.net that connects to an SSH server, makes some changes, and restarts the SSHD service on the SSH server. Unfortunately, the SSH server is being run on a slow embeded system, and the SSHD service is not restarted quickly enough to do so seamlessly (without disconnecting the client). The SSH service actually takes about a minute to restart. This is fine. My code looks this: Console.WriteLine("Restarting SSHD service on modem..."); try { using (var client

C# SSH.NET CreateCommand/RunCommand does not work

别说谁变了你拦得住时间么 提交于 2020-07-19 08:46:42
问题 I would like to create an application to send SSH commands to HP Switches and some other devices. But from HP Switch I get response "SSH command execution is not supported." . I use this part of a code. SshClient sshclient = new SshClient(IP,username, pass); sshclient.Connect(); SshCommand sc = sshclient.CreateCommand("conf"); sc.Execute(); string answer = sc.Result; label9.Text = answer; Any ideas how to make the interactive shell emulation? I found only this thread regarding to this issue.

Run and execute multiple dependent SSH commands using C#

筅森魡賤 提交于 2020-06-13 07:02:18
问题 I want to change directory inside SSH using C# with SSH.NET library: SshClient cSSH = new SshClient("192.168.80.21", 22, "appmi", "Appmi"); cSSH.Connect(); Console.WriteLine("current directory:"); Console.WriteLine(cSSH.CreateCommand("pwd").Execute()); Console.WriteLine("change directory"); Console.WriteLine(cSSH.CreateCommand("cdr abc-log").Execute()); Console.WriteLine("show directory"); Console.WriteLine(cSSH.CreateCommand("pwd").Execute()); cSSH.Disconnect(); cSSH.Dispose(); Console

Run and execute multiple dependent SSH commands using C#

空扰寡人 提交于 2020-06-13 07:01:27
问题 I want to change directory inside SSH using C# with SSH.NET library: SshClient cSSH = new SshClient("192.168.80.21", 22, "appmi", "Appmi"); cSSH.Connect(); Console.WriteLine("current directory:"); Console.WriteLine(cSSH.CreateCommand("pwd").Execute()); Console.WriteLine("change directory"); Console.WriteLine(cSSH.CreateCommand("cdr abc-log").Execute()); Console.WriteLine("show directory"); Console.WriteLine(cSSH.CreateCommand("pwd").Execute()); cSSH.Disconnect(); cSSH.Dispose(); Console

“SocketException: Could not resolve host” when connecting to SFTP server with SSH.NET

走远了吗. 提交于 2020-06-08 13:15:52
问题 Trying to upload file to SFTP server in my local. Hit error when connect SFTP. System.Net.Sockets.SocketException: Could not resolve host 'sftp://localhost' I've tried using command-line and FileZilla to connect. It can connected. string host = "sftp://localhost"; int port = 22; string username = "gth"; string password = "1234"; using (SftpClient client = new SftpClient(host, port, username, password)) { client.Connect(); } It show me error below: Loaded assembly: System.Threading.Tasks.dll

Copying or moving a remote file using SSH.NET with C#

送分小仙女□ 提交于 2020-05-10 06:48:10
问题 I know that I can upload and download files from/to a SFTP server using SftpClient class of SSH.NET library but I am not sure how can this class be used for copying or moving a remote file on the SFTP server. I also did not find relevant material on internet. How can i copy or move a remote file from directory A to directory B, using SSH.NET library and C#. Update: I also tried experimenting with SshClient class using the below code but it does nothing, neither any error nor any exception.

Copying or moving a remote file using SSH.NET with C#

喜夏-厌秋 提交于 2020-05-10 06:47:46
问题 I know that I can upload and download files from/to a SFTP server using SftpClient class of SSH.NET library but I am not sure how can this class be used for copying or moving a remote file on the SFTP server. I also did not find relevant material on internet. How can i copy or move a remote file from directory A to directory B, using SSH.NET library and C#. Update: I also tried experimenting with SshClient class using the below code but it does nothing, neither any error nor any exception.

SSH.NET CreateShellStream()

百般思念 提交于 2020-02-21 07:01:59
问题 I am building an application, SWSH, which is a ssh client. I am having trouble using the CreateShellStream() function. My code: using (var ssh = new SshClient(ccinfo)) { var keepgoing = true; ssh.Connect(); string terminalName = "xterm-256color"; uint columns = 80; uint rows = 160; uint width = 80; uint height = 160; // arbitrarily chosen int bufferSize = 500; IDictionary<Renci.SshNet.Common.TerminalModes, uint> terminalModeValues = null; var actual = ssh.CreateShellStream(terminalName,

Setting the extended file attributes using SSH.NET SftpClient

纵然是瞬间 提交于 2020-01-13 17:58:28
问题 I am trying to use the extended file attribute to store some information after I uploaded a file into remote machine (Ubuntu 16.04 LTS) from Windows using Renci SSH.NET SFTP library. But the attributes are not getting preserved? This how I am trying to set the extended attributes SftpFileAttributes fileAttrs = sftpClient.GetAttributes(remoteFilePath); IDictionary<string, string> additionalAttrs = new Dictionary<string, string>(); additionalAttrs.Add(new KeyValuePair<string, string>("user.from