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

New Post: sftp download file

$
0
0
@abedi98:
Is E:\abedi a directory ?
You should specifiy a file path as argument for the FileStream constructor.

Hope this helps,
Gert

New Post: SCP upload speed

$
0
0
What version of SSH.NET are you using ?
Performance of SftpClient has improved substantially in the latest beta release.

PS. I know the beta is dated, but there'll be a new beta release soon.

New Post: Proxy issue with Sftp class (client) with Renci.SshNet library

$
0
0
This should do it:
using Renci.SshNet;

namespace SshNetTests
{
    class Program
    {
        public static void Main()
        {
            var privateKeyAuthenticationMethod = new PrivateKeyAuthenticationMethod("<user>",
                new PrivateKeyFile(@"<path to private key>"));
            var connectionInfo = new ConnectionInfo("<SSH server hostname or IP address>",
                                                    22,
                                                    "<user>",
                                                    ProxyTypes.Http,
                                                    "<proxy server hostname or IP address>",
                                                    8080,
                                                    "<proxy user>",
                                                    "<proxy password>",
                                                    privateKeyAuthenticationMethod);

            using (var sftpClient = new SftpClient(connectionInfo))
            {
                sftpClient.Connect();
            }
        }

    }
}

New Post: SSH.NET

$
0
0
What version of SSH.NET are you using ?
Can you verify whether SshClient.IsConnect is still true after the exception ?

Also try subscribing to the Exception event to learn more on the reason why the connection was dropped:
            using (var client = new SftpClient(...))
            {
                client.ErrorOccurred += (sender, args) => Console.WriteLine(args.Exception);
                client.Connect();
                ...
            }

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: ericbruno **

Hi,

first of all, thank you for providing this useful library.

I use version 2014.4.6.0, built from the source available in the Downloads section. I experience the same issue. Downloading any file above ~15k fails. Here's the code (skeleton with "real" values where applicable):

```
using (var sftp = new SftpClient(url, user, pw))
{
sftp.Connect();
sftp.SendKeepAlive();
sftp.OperationTimeout = TimeSpan.FromSeconds(3600);

var dirFiles = sftpClient.ListDirectory("outgoing"); // find one file: "outgoing/a.zip"

string remoteFile = dirFiles[0];
string localFile = @"C:\a.zip";

using (FileStream downloadFS = new FileStream(localFile, FileMode.Create, FileAccess.Write))
{
sftpClient.DownloadFile(remoteFile, downloadFS); // this is where the error occurs
}

sftp.Disconnect();
}
```
StackTrace:
```
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 Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)

```

__NOTE__
The connection, file listing, etc. works great. And there is no issue with small-size files. Sample __a.zip__ is about 120k, which doesn't look excessive. Curiously, I was able to download much larger files using a previous (2013.4.7.0) version of SSH.NET.

If there's another way of requesting a download, I'm happy to re-implement.

Thanks for any pointers/help.
Eric

New Post: Channel is closed error on Disconnect

$
0
0
Hi,
I get the channel is closed error on calling disconnect on the SftpClient. Not sure what's happening.

Thanks.

New Post: Channel is closed error on Disconnect

$
0
0
This is the stacktrace of the error

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at Renci.SshNet.Sftp.SftpSession.SendMessage(SftpMessage sftpMessage)
at Renci.SshNet.Sftp.SftpSession.SendRequest(SftpRequest request)
at Renci.SshNet.Sftp.SftpSession.RequestClose(Byte[] handle)
at Renci.SshNet.Sftp.SftpFileStream.Dispose(Boolean disposing)
at Renci.SshNet.Sftp.SftpFileStream.Finalize()

New Post: Running nuhup command using SSH.NET

$
0
0
I'm having the same problem in my application. I become only error 126. Can you please help us?

New Post: Help with Running Applications

$
0
0
Maybe it's bit off topic, but when I'm trying to run nohup with whatever command I become only error 126. Can you please help me?

New Post: Running nuhup command using SSH.NET

$
0
0
126 means "Permission Denied".
» ssh test "nohup /dev/null"; echo $?
nohup: failed to run command ‘/dev/null’: Permission denied
126

New Post: Channel is closed error on Disconnect

$
0
0
One could consider this a bug in SSH.NET, but I'm inclined to say that you should close/dispose the SftpFileStream or StreamReader/StreamWrter that you obtained by invoking a method on SftpClient before disconnecting.

Can you review your code to make sure you're closing/disposing properly ?

Thanks!

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: drieseng **

Eric,

Are you able to reproduce this issue consistently with 2014.4.6.0 beta 1?
I've been finishing up some changes lately, but after that I'd really like to get to the bottom of this.
You can't reproduce this issue against a public SSH server by any chance ?

Cheers,
Gert

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: ericbruno **

Gert,

thanks for your reply. I built the SSH.NET I use from the 2014.4.6.0 beta 1 code base.

Good thing you suggested testing on a public SSH server. I set up a small SFTP server at work and tested downdloads/uploads from there - _successfully_. So the issue is not the size, although I do think it helps manifest it. But downloads still fail with the same file on the customer's SFTP site. And for maximum confusion: I can download/upload the same file from the FileZilla UI.

Here's where my SFTP server and the customer's server differ: the customer's SFTP activity is monitored programmatically. When the download completes for a given file, I can't delete it; instead, the system automatically relocates it to a subfolder on the SFTP, as though this behavior was event-driven. Same thing for uploads: once the transfer completes, the file is automatically moved to a subfolder. I can't be more specific about it - that's all I was told.

In any case, I would speculate that once a number of bytes (= buffer size?) have been read, when SSH.NET tries to read in the next buffer, that monitoring system seems to close the door on it.

Hope this helps.
Eric

New Post: Channel is closed error on Disconnect

$
0
0
Thanks a lot. There was a Streamreader open. Problem fixed now!

Created Unassigned: Backspace in ssh stream output [2570]

$
0
0
Hi, I have no issues when using SshCommand.Execute(). However, when I create a ShellStream and attach to a StreamReader object, when I submit commands I tend to get garbled output like so:

perl -e \"use LWP::Simple; my @info = head(\\\"https://files.example.\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bfo = head(\\\"https://

..... snip

That is, the stream output is littered with backspaces, and the number of backspaces sometimes but don't necessarily match the number of corrections I'd expect.

Example above: that's 64 backspace characters, but you can see that it only seems to back up 34 characters before starting from ... "fo = head" again.

Anyone have an idea about either of these?

1. Why is it doing this "correcting" at all?
2. Why don't the number of backspaces match the number of corrected characters?

Thanks much for insight anyone can provide.

New Post: SCP upload speed

$
0
0
I am using
2014.4.6-beta1
as downloaded from download page.
I still have the feeling it is a lot faster (50%+) compared to Tamir.ssh, which already is helpful.
I have to transfer files of ~50MB, here you can already notice any speed difference.

New Post: Running nuhup command using SSH.NET

$
0
0
But when I'm using PuTTY, or running the same command without nohup it's all fine. And maybe I've made a mistake, it's not error code 126, but exit status 126.

New Post: Running nuhup command using SSH.NET

$
0
0
Check the content of STDOUT and STDERR.

According to the nohup man page:
126 nohup found the utility program but could not invoke it.
RunCommand() is not the same like starting the command in a full (Putty-)Shell.
You have to compare it to the command option of your ssh client (e.g. plink):
C:\Windows\System32>"c:\Program Files (x86)\PuTTY\plink.exe" test "nohup /dev/null"
nohup: failed to run command ÔÇÿ/dev/nullÔÇÖ: Permission denied
This does the same like RunCommand() in SSH.NET.

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: scottowa **

Hello Gert,

Thanks for the library it is really good.

It seems like I have hit the same problem - I am fine reading small files (40Kb) but when I went to a slightly larger file(140Kb) - I hit the same disconnect error.

I am using almost exactly the same code as Eric and I can download the same file using Filezilla without any problems as well.

The stack trace is:

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 Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)

I have tried tinkering with:

sftp.BufferSize = 1024 * 256 - 50;
sftp.SendKeepAlive();
sftp.OperationTimeout = TimeSpan.FromSeconds(3600);
sftp.ConnectionInfo.Timeout = TimeSpan.FromSeconds(3600);

Nothing seems to help.

Many Thanks,

Adrian

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: drieseng **

Adrian,

You don't happen to have a public server available on which I can reproduce this issue ?
Can you check if any data at all was written to the stream after the exception is thrown ?
Do you have access to the logs on the SSH server ?

I'd really like to fix this issue before releasing a new beta.

Thanks!
Gert

Viewing all 2955 articles
Browse latest View live


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