ssh.net

Downloading and returning a non blocking stream of data using SSH.Net

别等时光非礼了梦想. 提交于 2019-12-07 15:48:20
问题 I am using the ssh.net library for performing SFTP operations to work with large data files ( >=500MB ) I am having an issue with how to return the data in a non-blocking way. The ftpClient.DownloadFile() method signature is ok, when writing to a file or if there's some way I can instantiate the stream, but am having problems on how to use it when I want to return a stream without blocking. All the examples I have seen so far will be writing the download to a Filestream . Nothing that just

C# Renci.SshNet.Sftp Connect throwing ArgumentNullException

主宰稳场 提交于 2019-12-06 15:21:52
I am using Renci.SshNet.Sftp to connect to SFTP. I am getting the following error when I try to call sftpClientObject.Connect() . Please find below the error. It was working fine couple of days ago. Checked the authentication details and it is perfect. var _sftpClient = new SftpClient(_hostName, _userName, _password); using (_sftpClient) { _sftpClient.Connect(); // Other code to follow } Error: Value cannot be null. Parameter name: At least one element in the specified array was null. Exception stacktrace: at System.Threading.WaitHandle.WaitAny(WaitHandle[] waitHandles, Int32

Modified date time changes when moving a file from Windows to UNIX server using SSH.NET

我们两清 提交于 2019-12-06 13:56:27
I am using SSH.NET in my C# application to copy files from a Windows to a UNIX server, I have a few scenarios for this: In the UNIX server directory if the file to be copied does not exist , then the modified datetime of the file when it is copied to the UNIX server changes to the copied datetime ? Is this correct because the modified datetime is not supposed to change right? In the UNIX Server directory if the file to be copied already exists , then on copying the same file which gets replaced in the UNIX Server path the modified datetime of the file does not change ! I am confused with this

SSH.NET passwd not executing

久未见 提交于 2019-12-06 13:44:36
问题 I can't seem to make this library to work. I'm doing something pretty straightforward but still I can't manage to do it. client.Connect(); client.RunCommand("sudo passwd test"); Thread.Sleep(1000); client.RunCommand("testtest"); Thread.Sleep(1000); client.RunCommand("12345"); Thread.Sleep(1000); client.RunCommand("12345"); bool primera = true; client.Disconnect(); If I try then to login with test using the credentials just posted it fails. But if I do the same commands through normal SSH

Downloading a directory using SSH.NET SFTP in C#

会有一股神秘感。 提交于 2019-12-06 06:38:10
I am using Renci.SSH and C# to connect to my Unix server from a Windows machine. My code works as expected when the directory contents are only files, but if the directory contains a folder, I get this Renci.SshNet.Common.SshException: 'Failure' This is my code, how can I update this to also download a directory (if exists) private static void DownloadFile(string arc, string username, string password) { string fullpath; string fp; var options = new ProgressBarOptions { ProgressCharacter = '.', ProgressBarOnBottom = true }; using (var sftp = new SftpClient(Host, username, password)) { sftp

SSH.NET: Is it possible to upload files using SFTP and preserve the file dates from source files?

旧街凉风 提交于 2019-12-06 05:16:35
Currently, I am using the Renci SSH.NET library to upload files to a Unix server using SFTP. One thing that I don't like is that after uploading files, the creation- and modified dates are altered to the time when the upload took place. I would like to preserve the original file dates from the source files, is that possible? The SSH.NET library won't do it for you automatically. You have to code it. There are SftpClient.SetLastWriteTime and SftpClient.SetLastWriteTimeUtc methods. But they are actually not implemented yet. You can code it like this instead: SftpFileAttributes fileAttributes =

Downloading and returning a non blocking stream of data using SSH.Net

我的梦境 提交于 2019-12-06 02:24:35
I am using the ssh.net library for performing SFTP operations to work with large data files ( >=500MB ) I am having an issue with how to return the data in a non-blocking way. The ftpClient.DownloadFile() method signature is ok, when writing to a file or if there's some way I can instantiate the stream, but am having problems on how to use it when I want to return a stream without blocking. All the examples I have seen so far will be writing the download to a Filestream . Nothing that just returns a stream With .Net's built-in FTP, you just use response.GetResponseStream() , and it streams

2nd factor verification on every command through ssh.net

让人想犯罪 __ 提交于 2019-12-05 23:59:05
I am connecting to a Unix server using SSH.NET with the following code ssh = new SshClient("myserver.univ.edu", Username, Password); ssh.Connect(); The connection goes through and appears to generate no exception. The server is set up to require two factor authentication, but I get no prompt on my phone (using that as physical authenticator/OTP device). But the connection seems to be ok. I then issue a command with this code: SshCommand NewLookup = ssh.CreateCommand("newlookup " + IpNameOrAddress.Text)) LogText.Text += NewLookup.Execute().Replace("\n", Environment.NewLine); And then I get the

Renci SSH.NET: Is it possible to create a folder containing a subfolder that does not exist

和自甴很熟 提交于 2019-12-05 23:16:35
I am currently using Renci SSH.NET to upload files and folders to a Unix Server using SFTP, and creating directories using sftp.CreateDirectory("//server/test/test2"); works perfectly, as long as the folder "test" already exists. If it doesn't, the CreateDirectory method fails, and this happens everytime when you try to create directories containing multiple levels. Is there an elegant way to recursively generate all the directories in a string? I was assuming that the CreateDirectory method does that automatically. There's no other way. Just iterate directory levels, testing each level using

Setting the extended file attributes using SSH.NET SftpClient

安稳与你 提交于 2019-12-05 22:05:00
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", "abc")); additionalAttrs.Add(new KeyValuePair<string, string>("user.to", "xyz")); fileAttrs = new