Questions tagged [ssh.net]

SSH.NET is an open-source .NET port of the Java Sharp.SSH library and is available under the BSD and MIT license.

SSH.NET is an open-source, standalone implementation of the SSH-2 protocol, written in . It is dual licensed under the new BSD license and MIT license.

It supports several frameworks:

Links

376 questions
36
votes
3 answers

"Renci.SshNet.Common.SshException: Invalid private key file" when loading SSH private key from configuration string using SSH.NET

I'm trying to send a file to some server using SFTP. During this process I'm getting the exception Renci.SshNet.Common.SshException: Invalid private key file. at Renci.SshNet.PrivateKeyFile.Open(Stream privateKey, String passPhrase) Generated the…
Konduri Vikram
  • 360
  • 1
  • 3
  • 9
34
votes
4 answers

Unable to upload a file SFTP using SSH.NET in C# - Permission Denied

I am trying to upload a file using SFTP protocol using C# using SSH.NET library. Below is the code I am using FileInfo f=new FileInfo("C:\\mdu\\abcd.xml"); string uploadfile=f.FullName; …
Timothy Rajan
  • 1,947
  • 8
  • 38
  • 62
23
votes
2 answers

How to run commands on SSH server in C#?

I need to execute this action using a C# code: open putty.exe in the background (this is like a cmd window) login to a remote host using its IP address enter a user name and password execute several commands one after the other. run another command…
Liran Friedman
  • 4,027
  • 13
  • 53
  • 96
19
votes
3 answers

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

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…
user1451111
  • 1,735
  • 3
  • 18
  • 30
18
votes
6 answers

SSH.NET SFTP Get a list of directories and files recursively

I am using Renci.SshNet library to get a list of files and directories recursively by using SFTP. I can able to connect SFTP site but I am not sure how to get a list of directories and files recursively in C#. I haven't found any useful examples.…
user1462119
  • 303
  • 1
  • 2
  • 5
17
votes
3 answers

Using "OPENSSH" private key file in string with SSH.NET in C# fails with "invalid private key file"

I'm not experienced with SFTP or OpenSSH. I am trying to connect to a client's SFTP to upload a file. I am using the SSH.NET library – https://github.com/sshnet/SSH.NET Within my C# code I have the private key in a string variable: var key =…
andrewb
  • 2,995
  • 7
  • 54
  • 95
16
votes
3 answers

SSH.NET Authenticate via private key only (public key authentication)

Attempting to authenticate via username and privatekey only using the current SSH.NET library. I cannot get the password from the user so this is out of the question. here is what i am doing now. Renci.SshNet.ConnectionInfo conn = new…
petey m
  • 305
  • 1
  • 4
  • 14
16
votes
2 answers

Creating a forwarded port within an SSH tunnel

I'm attempting to use SSH.NET to create a tunnel from localhost:3306 to port 3306 on a remote machine: PrivateKeyFile file = new PrivateKeyFile(@" .. path to private key .. "); using (var client = new SshClient(" .. remote server .. ", "ubuntu",…
Adrian Wragg
  • 7,311
  • 3
  • 26
  • 50
14
votes
1 answer

Is it possible to work on normal (not SFTP) FTP on Renci SSH.NET? - which client to use?

I am using Renci SSH.NET, but trying to test on a FTP (not SFTP site). I did get this working with WinSCP - but cannot get it to work on Renci - WinSCP allows me to set the protocol to either FTP or SFTP - I think this is the issue - I am prompted…
Peter PitLock
  • 1,823
  • 7
  • 34
  • 71
13
votes
2 answers

Upload whole folder with SSH.NET

I use SSH.NET in C# 2015. With this method I can upload a file to my SFTP server. public void upload() { const int port = 22; const string host = "*****"; const string username = "*****"; const string password = "*****"; const…
Francis
  • 343
  • 2
  • 5
  • 16
13
votes
7 answers

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

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,…
Erik
  • 2,316
  • 9
  • 36
  • 58
13
votes
1 answer

SSH.Net Async file download

I am trying to download files asynchronously from an SFTP-server using SSH.NET. If I do it synchronously, it works fine but when I do it async, I get empty files. This is my code: var port = 22; string host = "localhost"; string username =…
spersson
  • 538
  • 1
  • 8
  • 19
11
votes
2 answers

Randomly getting Renci.SshNet.SftpClient.Connect throwing SshConnectionException

I've seen other threads about this error, but I am having this error randomly. Out of 30 connects, 12 got this error. Trying to understand why this is, and what possible solutions are. using (SftpClient client = new SftpClient(sftpHost, sftpPort,…
Razkar
  • 539
  • 5
  • 26
11
votes
1 answer

SSH.Net SftpClient: do I need to call Disconnect within using block?

In a code like this using (var sftp = new SftpClient(_host, _userName, _password)) { sftp.Connect(); // Do some work with sftp sftp.Disconnect(); } Is sftp.Disconnect() call necessary or will using block (Dispose/Close/whatever) close…
vkelman
  • 1,501
  • 1
  • 15
  • 25
11
votes
3 answers

How to save downloaded files in MemoryStream when using SSH.NET

I am using SSH.NET library to download files. I want to save the downloaded file as a file in memory, rather than a file on disk but it is not happening. This is my code which works fine: using (var sftp = new SftpClient(sFTPServer, sFTPPassword,…
user1451111
  • 1,735
  • 3
  • 18
  • 30
1
2 3
25 26