Quantcast
Channel: SSH.NET Library
Viewing all 2955 articles
Browse latest View live

New Post: Very long process failing for SshClient....

$
0
0
var cmd = client.CreateCommand("cd current; script/run_publisher_complete.sh armstrong_ceilings");

This is a process that takes almost 20 minutes to run in putty - but returns almost immediately in C#. What am I doing wrong? There is no output to the Output window, and no errors or exceptions being thrown.

Thanks

Reviewed: 2014.4.6-beta1 (8月 27, 2014)

$
0
0
Rated 5 Stars (out of 5) - This is really a good job. I only use ssh command and sftp. It works well.

Reviewed: 2014.4.6-beta1 (八月 28, 2014)

$
0
0
Rated 5 Stars (out of 5) - Hello, may I know if you are interested to find Sponsor for your product? And we want to be your sponsor. Please mail me cxienancy@gmail.com for detailed information. Thank you very much.

Created Unassigned: System.InvalidOperationException: Dynamic operations can only be performed in homogenous AppDomain [2401]

$
0
0
Hi All,

I am trying to connect to FTP using your binaries and getting below error:
System.InvalidOperationException: Dynamic operations can only be performed in homogenous AppDomain. at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle) at Renci.SshNet.Session.Connect() at Renci.SshNet.BaseClient.Connect()...

My scenario is I am using SharePoint 2013 List event receiver to upload file in SFTP shared location which is working successfully.
I am trying to read the file from same shared location and getting above error. The only thing which is different here is, for reading I am using SharePoint 2013 Timer Job.

Quick response would be appreciated.

New Post: Strings longer than 2147483647 is not supported

$
0
0
Hello,

I am getting the following error in ReadBinaryString() in SSHData..
"Strings longer than 2147483647 is not supported"

Here is the details on what I am doing.

ConnectionInfo conn = new ConnectionInfo("111.111.111.111", 222, "user", new PasswordAuthenticationMethod("user", "password"));

SftpClient sftp = new SftpClient(conn);

sftp.Connect();

I get the error on the connect call. I am calling a NAT address that maps to a client mainframe as the Host. There is a site 2 site VPN set up. I can connect through Filezilla. 222 is the used port.

Also to note... When I "Resume Next" on the error the SSH source code, the connection appears to be established. That is I can ListDirectory after. Seems to be an issue with the message size but I don't know if the message is telling me something is wrong.

Any suggestions on what I could do would be appreciated.

New Post: SSH RSA privatekeys? with passphrase?

$
0
0
Hello,

I am still getting similar error "DER length is '43' and cannot be more than 4 bytes." using the latest release 2014.4.6-beta1 . Is there a fix for this or is AES still not supported?

New Post: System.InvalidOperationException: Dynamic operations can only be performed in homogenous AppDomain

$
0
0
I am trying to connect to FTP using your binaries and getting below error:
System.InvalidOperationException: Dynamic operations can only be performed in homogenous AppDomain. at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle) at Renci.SshNet.Session.Connect() at Renci.SshNet.BaseClient.Connect()...

My scenario is I am using SharePoint 2013 List event receiver to upload file in SFTP shared location which is working successfully.
I am trying to read the file from same shared location and getting above error. The only thing which is different here is, for reading I am using SharePoint 2013 Timer Job.

Quick response would be appreciated.

Commented Unassigned: SftpClient ctor throws exception when hostname has _ character [1845]

$
0
0
The constructor for SftpClient and SshClient class throws an ArgumentException when the hostname has an underscrore character '_' . Using disassembly I can find the issue is the regex _rehost in Extensions.cs

This regex should be fixed as _ is valid hostname.
Comments: ** Comment from web user: StephenMills **

I ran into this as well. I agree it should be fixed as DNS does allow you to use _ in a hostname. You aren't supposed to use it, which is probably why the restriction was put in, but it does actually allow it. So please fix this, as I can't use this very well right now and it is otherwise very useful.

Thanks.


New Post: SSH Tunnel HTTP GET Request

$
0
0
Hi, my name is Nick and i have just foud out about SSH.NET. (felicita !)
I use VB.NET (beginer) and my question is : How can i build a HTTP GET request without port forwarding ? I just want to open the tunnel and send the http get command and recive the actual webpage that i want to visit, but with no port forwarding involved. is that possible ? And if yes, can you please guide me? Thanks in advance.

Nick

New Post: VB.net SSH client with VB.net

$
0
0
Hi -
( my VB is mot the best ... so if response is in C# ..then i'm goosed !)
I want to write a vb app that will :
  1. Connect to a device through SSH.
  2. Send a list commands and wait for the response of each command, before sending the next.
    I'd like each response to go to a textbox.
I've seen sharpssh which I can get to work - kind of - but I have to put in the expected prompt for each command ... I don't want to do that .. I just want to see the full response in the textbox ... before I send the next command.

I've also seen renci .. but for some reason cant get that to work

For sharpssh - I don't want to have to enter something for sshstr.prompt .. I just ant to see the full responce..

any ideas how I could do this ?
thanks



Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim result As String
    Dim sshstr As New SshStream("10.226.145.108", "super", "super")
    TextBox1.Text = "Connecting ...."
    Me.Refresh()

    sshstr.Prompt = "TSM"

    '//Remove terminal emulation characters
    sshstr.RemoveTerminalEmulationCharacters = True

    TextBox1.Text = sshstr.ReadResponse()
    TextBox1.Select(TextBox1.TextLength, 0)
    TextBox1.ScrollToCaret()
    MsgBox(" 1")
    System.Threading.Thread.Sleep(5000)
    Threading.Thread.Sleep(1000)
' command # 1
    sshstr.Write("/c 1")
    TextBox1.AppendText("/c 1")
    TextBox1.Select(TextBox1.TextLength, 0)
    TextBox1.ScrollToCaret()
    Me.Refresh()
    System.Threading.Thread.Sleep(2000)
     sshstr.Prompt = ""
    result = sshstr.ReadResponse()

    TextBox1.AppendText(result)
    TextBox1.Select(TextBox1.TextLength, 0)
    TextBox1.ScrollToCaret()
    Threading.Thread.Sleep(1000)
' command # 2
    sshstr.Write(Chr(24))
    sshstr.Write(Chr(13))
    TextBox1.AppendText("Chr(24)")
    TextBox1.Select(TextBox1.TextLength, 0)
    TextBox1.ScrollToCaret()
    Me.Refresh()
    sshstr.Prompt = "TSM"
    result = sshstr.ReadResponse()
    TextBox1.AppendText(result)
    TextBox1.Select(TextBox1.TextLength, 0)
    TextBox1.ScrollToCaret()
    sshstr.Close()

    ' //Reading from the SSH channel

End Sub

New Post: VB.net SSH client with VB.net

$
0
0
Hi bgengine,
You ask for something that is difficult. You are asking that the SSH Client somehow know that the server is done with a command, but you won't tell it how to recognize the output when it is done. Suppose a command takes a few seconds, or outputs some, waits, outputs more, etc.?

[IMHO] The only way you can consistently do this is with one of the following, or a combination:
  1. You tell the client what to look for in the return stream that signals the command is complete (this depends on the server quite a bit, as they all return something different-even based on the command(s) given), or
  2. You give it a timeout period. "After 10 seconds, I am assuming you have the output, and I can send more. If not, oh well!"
I don't use all kinds of ssh servers, so I can't give you advise. But if your server somehow 'echoes' back it's input, or you know the prompt it will return, that all helps. Also, another 'gotcha' is if you enter &nix-style commandS <-plural on the command line, separated by ;. Is that one command, or multiple? What about pipes and redirects? What about timed/cycle or 'tail' style commands that run until you cancel them? And what about rapid-fire/batch commands send as multiple lines?

You see, from the program's perspective, it can only recognize the end based on what you tell it it should recognize as the end of a command.

If you find a way to compensate/prepare for all of that, I would love to see it! :)

pat
:)

New Post: VB.net SSH client with VB.net

$
0
0
Thanks Pat for your response,

Ok _ I think I understand the issue ..

I don't fully understand ssh so please forgive my ignorance.. but I was wondering is it possible to put a timer on the ssh buffer ( if such a buffer exsists ?)
so that if the buffer has something in it - then read it and put it in the text box ....
When a command is sent - continually check the incoming buffer and dump the contents to the text box ... until the buffer is empty


Perhaps this is not possible ... I did something like this with a serial port buffer some time ago but I know very little about ssh..
regards

New Post: VB.net SSH client with VB.net

$
0
0
@bgengine,

I might suggest start messing with it to start.

I have posted many VB examples here. I will leave it to the experts to say for sure, but networking protocols don't talk the way hard-wired ones do. The buffer you're talking about in the serial world, when talking about the network world, is not a static thing that you can say "OK, it's empty". There is no way of knowing if another packet will arrive, and the 'buffer' be filled again.

I have described my approaches here, but basically there are 2 approaches (I alluded to them earlier). The subtlety being whether you know what to expect or not, and whether the response is really gig, or very small-or not at all. That alone can open a large discussion...

So what I do MOST of the time with a response I know will be large is this:
  1. I issue a command.
  2. I wait for the response (might take time, so I need to set a timer to decide "I give up waiting").
  3. If that timeout is not yet, I RESET an 'inactivity' timer to 0 every time I receive something.
  4. That inactivity timer also has a timeout period to say "I guess there is no more output!".
  5. As long as there is input, and the inactivity timer are below threshold, I continue to add to the input stream (the content I expected).
  6. At some point, one of the timers will expire, and I can't wait any longer. I put these timeouts in the Function() calls, as Optional with defaults.
  7. I return whatever I clumped together.
This works in my scenarios because I am not using SSH for files (I guess I could), but for text in/out, as in commands & responses. Most folks here are doing things much more exotic than I am-hell, I can't even figure out how to write tests! :)
  • So again, I suggest you put a small test project in your solution, and try (with Intellisense) a few options... And go back and read some of the excellent threads here where folks have posted their working code (like me) for your benefit. I didn't post it to help me, but to help you. :)
I think you will make much faster progress, and understand your choices for your scenario better. I chose this SSH util suite because it is current, useful & well written, and the support/forum/community is active. Sometimes I pose bizarre problems that nobody knows how to fix, but most times folks are eager to assist-probably a lot more so than on the elitist SO...

Go until you can't continue, try others' solutions, and when you get to a line/step you can't get past, post here.

pat
:)

Commented Unassigned: An established connection was aborted by the server [2398]

$
0
0
When trying to download files from sftp, I am getting error:"__An established connection was aborted by the server__"
Comments: ** Comment from web user: ShellyZhang **

I have the same problem.

An established connection was aborted by the server.

at Renci.SshNet.Sftp.SubsystemSession.WaitOnHandle(WaitHandle waitHandle, TimeSpan operationTimeout) at Renci.SshNet.Sftp.SftpSession.RequestRead(Byte[] handle, UInt64 offset, UInt32 length) at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback) at

New Post: Cannot find type [Renci.SshNet.SshClient]

$
0
0
I downloaded Renci.SshNet.dll and did all configuration.
While establishing session, I am getting this error
"Unable to create SSH client object for 127.0.0.1: Cannot find type [Renci.SshNet.SshClient]: make sure the assembly containing this type is loaded."

I also have downloaded Renci.SshNet file that contains all files with .cs but I dont think it is being taken anyway.

Please help me out with this.
Would be very grateful.

Thanks
Amit

New Post: Unable to install SSH-Sessions Powershell module

$
0
0
I'm getting this error:
Import-Module : Could not load file or assembly 'file:///C:\Program Files\WindowsPowerShell\Modules\ssh-sessions\Renci.SshNet.dll' or one of its dependencies. Operation is not
supported. (Exception from HRESULT: 0x80131515)

The files have been unblocked. On server 2012 R2. PS 4.0

New Post: SSH to terminal server and then TELNET to devices

$
0
0
I was successful in SSH to terminal server. However, when I telnet to a device from there, it just hangs up. It is waiting for Username as input. How do I solve this?

I need to SSH to Server
From Server telnet to Router
(Enter Username and Password)
Run "Show Run" on the router.

Any help is much appreciated.

Thanks in advance.

New Post: Zlib compression support

$
0
0
Thanks so much for this! I spent forever trying to get it working but didn't read carefully enough... For anyone reading this, don't forget to uncomment those two lines in ConnectionInfo.cs (CTRL-F "this.CompressionAlgorithms").

Created Unassigned: SSH.NET Upload Multiple files asynchronously throws an exception. [2408]

$
0
0
I am creating an application that will

process a CSV file,
create JObject for each record in CSV file, and finally
upload all these files to SFTP server
After looking around for a free library for the 3rd point, I decided to use SSH.NET.

I have created the following class to perform the upload operation asynchronously.

public class JsonFtpClient : IJsonFtpClient
{
private string _sfptServerIp, _sfptUsername, _sfptPassword;

public JsonFtpClient(string sfptServerIp, string sfptUsername, string sfptPassword)
{
_sfptServerIp = sfptServerIp;
_sfptUsername = sfptUsername;
_sfptPassword = sfptPassword;
}

public Task<string> UploadDocumentAsync(string sourceFilePath, string destinationFilePath)
{
return Task.Run(() =>
{
using (var client = new SftpClient(_sfptServerIp, _sfptUsername, _sfptPassword))
{
//ALL ERRORS ARE THROWN WHEN EXECUTING THIS LINE
client.Connect();

using (Stream stream = File.OpenRead(sourceFilePath))
{
client.UploadFile(stream, destinationFilePath);
}

client.Disconnect();
}

return (destinationFilePath);
});
}
}

The UploadDocumentAsync method returns a TPL Task so that I can call it to upload multiple files asynchronously.

I call this UploadDocumentAsync method from the following method which is in a different class:

private async Task<int> ProcessJsonObjects(List<JObject> jsons)
{
var uploadTasks = new List<Task>();
foreach (JObject jsonObj in jsons)
{
var fileName = string.Format("{0}{1}", Guid.NewGuid(), ".txt");

//save the file to a temp location
FileHelper.SaveTextIntoFile(AppSettings.ProcessedJsonMainFolder, fileName, jsonObj.ToString());

//call the FTP client class and store the Task in a collection
var uploadTask = _ftpClient.UploadDocumentAsync(
Path.Combine(AppSettings.ProcessedJsonMainFolder, fileName),
string.Format("/Files/{0}", fileName));

uploadTasks.Add(uploadTask);
}

//wait for all files to be uploaded
await Task.WhenAll(uploadTasks);

return jsons.Count();
}

Although the CSV file results in thousands of JSON records, but I want to upload these in batches of at least 50. This ProcessJsonObjects always receives a list of 50 JObjects at a time which I want to upload asynchronously to the SFTP server. But I receive the following error on client.Connect(); line of the UploadDocumentAsync method:

Session operation has timed out
Decreasing the batch size to 20 results in the following error:

Client not connected.
But this also uploads 3 files to the SFTP server as well, but not all the 20.

What am I doing wrong? Your help is much appreciated.

New Post: System.InvalidOperationException: Dynamic operations can only be performed in homogenous AppDomain

$
0
0
Somewhere in your app.config file you have <legacyCasPolicy enabled="true" />

You can remove this and it will work (if you don't require it).


Problem is I have the same issue but i need the legacyCasPolicy to be enabled. Any ideas of any alternatives please?
Viewing all 2955 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>