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

Commented Unassigned: [Retracted] Random Exception on multi-handle wait [1757]

$
0
0
I use renci.sshnet in a multi-threaded/multi-concurrent-connection environment and was observing randome generic exceptions being thrown during heavy testing.

> Using Revision: 28765

The problem was found in Session.cs lines 637 through 646:
```
switch (EventWaitHandle.WaitAny(waitHandles, this.ConnectionInfo.Timeout))
{
// case 0:
// throw this._exception;
case System.Threading.WaitHandle.WaitTimeout:
this.SendDisconnect(DisconnectReason.ByApplication, "Operation timeout");
throw new SshOperationTimeoutException("Session operation has timed out");
default:
break;
}
```
With lines 639 and 670, here commented out, the random general exception was no longer thrown. Upon inspection it was found that the __WaitAny()__ call returns a zero base index to the event handle, in the passed in array of handles, that caused the wait to release. Thus, zero is a valid return value implying wait success. It should not have thrown an exception.
Comments: ** Comment from web user: JohnRo **

I need to retract this recommended fix. In reviewing the code I realized that the zero index event is being added to the passed in array of wait handles to represent an exception event elsewhere in the communicaiton process. A comment would have helped me understand that the zero index handle was intended to throw and exception by design.


New Post: Trouble with Space in SSH-Command

$
0
0
Hi,

i have a problem with remote-excution of commands when they include a space.
There is a working connection to a firewall (http://www.securepoint.cc/products-utm-firewalls.html) and i can use single-term commands (i.e. "help"), but not "appmgmt status". It seems to me, that the firewall interprets the command as two commands - it returns alway "--unknown command". With Putty it works like a charm.

I wrote a simple test-application to clarify the issue:
ConnectionInfo sLogin = new PasswordConnectionInfo(_host, _user, _password);
            SshClient sClient = new SshClient(sLogin);
            sClient.Connect();

            SshCommand appStatCmd = sClient.CreateCommand("help");
            appStatCmd.Execute();
            textBox1.Text = appStatCmd.Result;
            
            sClient.Disconnect();
            sClient.Dispose();     
I also tried to change the encoding of the command, without luck.

Target-Framework is 4.0, working on a Windows 2008 SP2 x64 RDS with Visual Studio 2010 Pro.

Any help will be appreciated.

Reviewed: 2013.4.7 (Sep 06, 2013)

$
0
0
Rated 5 Stars (out of 5) - The examples were straight forward. I am using the DLL and the sftp is working perfectly so far.

New Post: 3.5 Binary Copyright Incorrect

$
0
0
The 3.5 binary copyright is currently:

Copyright Microsoft 2011

I think this should be:

Copyright (c) 2013, RENCI
All rights reserved.

Can you please correct so we can re-distribute the binary according to the license?

Created Unassigned: Incorrect copyright [1764]

$
0
0
The 3.5 binary copyright is currently:

Copyright Microsoft 2011

I think this should be:

Copyright (c) 2013, RENCI
All rights reserved.

Can you please correct so we can re-distribute the binary according to the license?

New Post: Problem with SftpClient - ListDirectory and iso-8859-1

$
0
0
Hi There,

I am having similar issue with SSH.Net while listing .txt file names from SFTP location. There are Chinese characters in the files names available on SFTP location. At the UI end I want to list them to user so that user can download the desired file. But the file name are not displaying correctly instead it displays like "?????.txt".

When I list the same files from my machine using default directly display functions, it works fine. I’ve checked the server as well and everything is okay like server locale, file names on the server etc.

I tried to modify the SSH.Net source code as well but no luck. Can anyone please help what am I missing?

Please reply ASAP.

Many Thanks,

Commented Unassigned: SSH through Proxy Problem [1601]

$
0
0
Hello guys,

im trying to connect through a proxy to my SSH server but i get an exception:
"__Renci.SshNet.Common.SshOperationTimeoutException: Socket read operation has time
d out
at Renci.SshNet.Session.SocketReadLine(String& response)
at Renci.SshNet.Session.ConnectHttp()
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.Connect()
at UAMT.MyClasses.RenciSSH..ctor() in D:\Project\MyClasses\RenciSSH.cs:line 36__".
In the Java Console i can see that it is connecting to Proxy but cant get connection to server. I placed the exe on a local pc and connected successfully to the SSH server without going through proxy. I tryed to connect with PuTTY using the same configuration (with proxy) and it worked fine. I also tryed another lib "Chilkat" and it worked fine (__without KeyAuthentification__) too but you have to buy a license to unlock the trial version and other libs dont support proxy functionality..... :(

the code im using:

ConnectionInfo connectionInfo = new ConnectionInfo("xx.xx.xx.xx", 22, "username", ProxyTypes.Http, "127.0.0.1", 18080, "", "", new PasswordAuthenticationMethod("username", "password"));

try
{
using (var ssh = new SshClient(connectionInfo))
{
ssh.Connect();

ssh.RunCommand("ls -l");

ssh.Disconnect();
}
}
catch (Exception ex)
{
Console.WriteLine();
}

Am i doing something wrong with ssh.net (maybe a flag that need to be set or something)?

Thanks in advance

killikax
Comments: ** Comment from web user: xboixed **

Hi killikax,

I've had the same issue and was due to a bug in the Session.ConnectHttp method where there is an infinite loop (which is the reason of the TimeOut exception). Indeed, when dealing with the HTTP response, the status.OK should break the loop but it just breaks the select case instead and results in the mentioned infinite loop. The correction should be (in Session.ConnectHttp) :

```
switch (statusCode)
{
case HttpStatusCode.OK:
return; // instead of break;
default:
throw new ProxyException(string.Format("HTTP: Status code {0}, \"{1}\"", statusCode, statusCode));
}

```
Hope this solves your issue

New Post: Port fowarding not keep alive

$
0
0
Hi,

Im trying to make an app which allows port fowarding features (using for change ip address) using SSH Tunnel.
Renci.SshNet.SshClient ssh = new Renci.SshNet.SshClient("174.34.150.202", "admin", "admin");
            ssh.Connect();
            
            Renci.SshNet.ForwardedPortDynamic port_fowarding = new Renci.SshNet.ForwardedPortDynamic(1080);
            port_fowarding.Exception += new EventHandler<Renci.SshNet.Common.ExceptionEventArgs>(port_fowarding_Exception);
            port_fowarding.RequestReceived += new EventHandler<Renci.SshNet.Common.PortForwardEventArgs>(port_fowarding_RequestReceived);
            ssh.AddForwardedPort(port_fowarding);
            port_fowarding.Start();
These code working fine after sometimes. But just around 30 second then i get an error:
Client not connected.
Looking as Socket has disconnected. How can i keep the port fowarding longer (around few hours or forever)

Thanks!

New Post: Encoded File Names not Displaying Correctly.

$
0
0
Hi There,

I am having similar issue as postd in (https://sshnet.codeplex.com/discussions/372745) with SSH.Net while listing .txt file names from SFTP location. There are Chinese characters in the files names available on SFTP location. At the UI end I want to list them to user so that user can download the desired file. But the file name are not displaying correctly instead it displays like "?????.txt".

When I list the same files from my machine using default directly display functions, it works fine. I’ve checked the server as well and everything is okay like server locale, file names on the server etc.

I tried to modify the SSH.Net source code as well but no luck. Can anyone please help what am I missing?

Please reply ASAP.

Many Thanks,

New Post: Different Port ?

$
0
0
My question is simple, how i can change the port?
An example code,would be nice,I am newbie,srry,

New Post: Trouble with Space in SSH-Command

Created Unassigned: DerData.GetLength buggy [1766]

$
0
0
Hello,

I just noticed, that the DerData.GetLength method is buggy. For example. A length of 128 in DER-Format would be

0xF1 0xF0 (0xF1 indicating a total of 1 octet, and 0xF0 the single octet representing 128)

But the source code would only return an byte[] Array of size 1.

Like

```
private byte[] GetLength(int length)
{
if (length > 127)
{
int size = 1;
int val = length;

while ((val >>= 8) != 0)
size++;

// here it must be new byte[size + 1] to have place for the octects AND the octect count byte
var data = new byte[size + 1];
data[0] = (byte)(size | 0x80);

for (int i = (size - 1) * 8, j = 1; i >= 0; i -= 8, j++)
{
data[j] = (byte)(length >> i);
}

return data;
}
else
{
return new byte[] { (byte)length };
}
}
```

Greetz
Christian

New Post: Transfer the File minimum 49,152 bytes using SFTP

$
0
0
I don't know why, but i found the default buffer size of the client connection is 16k, and when the upload starts, with files over 16kb, the client waits to the buffer will be free again, but this never occur and the timeout is throwing.

To solve that, I'm setting the buffer size to a minor value and it's works fine:
                AuthenticationMethod am = new PasswordAuthenticationMethod(tbUser.Text, tbPsw.Text);
                ConnectionInfo ci = new ConnectionInfo(tbHost.Text, int.Parse(tbPort.Text), tbUser.Text, new AuthenticationMethod[] { am });                                                

                _sftpClient = new SftpClient(ci);
                _sftpClient.BufferSize = 1024 * 8 - 50;

                _sftpClient.Connect();              
Hope it helps

Created Unassigned: Performance degredation [1767]

$
0
0
[Release 2013.4.7]
In the file Session.cs there are the lines:

[664] this.Log(string.Format("SendMessage to server '{0}': '{1}'.", message.GetType().Name, message.ToString()));

[1542] this.Log(string.Format("ReceiveMessage from server: '{0}': '{1}'.", message.GetType().Name, message.ToString()));

These lines are additions from the previous release where they were commented out.

Under testing I have found that when writing data there is approximately a 50% performance degredation, ie. in my test, the previous software release (without these logging statements), managed a transfer rate of approximately 700Kbps which degraded to approximately 300Kbps with the logging statements added in.

I have only tested write performance, but I have double-checked that the cause of the performance degredation is definitely due to the logging statements. Currently I have them both disabled in my local copy.

Can I suggest that these statements are temporarily removed?

Thank you.

New Post: Control M charecters

$
0
0
Hi,

While am uploding a file from windows to linux(SUSE), getting special charecter(contrl M) at the end of the each line. Please let me know how to getrid of these special charecters.

Thanks
John

New Post: An established connection was aborted by the software in your host machine

$
0
0
Can anyone shed some light on this issue? Thanks in advance

Renci.SshNet.Common.SshConnectionException: An established connection was aborted by the software in your host machine.
at Renci.SshNet.Session.WaitHandle(WaitHandle waitHandle) in *\Renci.SshNet\Session.cs:line 640
at Renci.SshNet.Channels.Channel.Close(Boolean wait) in *\Renci.SshNet\Channels\Channel.cs:line 518
at Renci.SshNet.Channels.ChannelSession.Close(Boolean wait) in *\Renci.SshNet\Channels\ChannelSession.cs:line 106
at Renci.SshNet.Channels.Channel.Close() in *\Renci.SshNet\Channels\Channel.cs:line 223
at Renci.SshNet.Sftp.SubsystemSession.Disconnect() in *\Renci.SshNet\SubsystemSession.cs:line 106
at Renci.SshNet.SftpClient.OnDisconnecting() in *\Renci.SshNet\SftpClient.cs:line 1563
at Renci.SshNet.BaseClient.Disconnect() in *\Renci.SshNet\BaseClient.cs:line 130
at MichelinPortal._Default.SendFile(String filePath, String fileName) in *\Default.aspx.cs:line 394

New Post: Different Port ?

$
0
0
I am also curious about how to change the port. Please answer!

New Post: Different Port ?

$
0
0
It seems like I have found the solution:

Dim connInfo as new Renci.Sshnet.PasswordConnectionInfo(host, port, username, password)
Dim sftpclient as new Renci.Sshnet.SftpClient(connInfo)

sftpclient.connect()

New Post: Problem to connect using the PROXY Squid

$
0
0
I have a problem to connect with the server SFTP (SSH Server Bitvise 5.54) when using the PROXY (Squid Cache: Version 2.7.STABLE8) filezilla client (version 3.7.3) if the connection succeeds, but with the library renci.sshnet (version 2013.4.7) SFTP I get to where I see the connection attempt, but sshnet returns the exception "Socket read operation has timed out"

New Post: Issues with sftpclient downloads

$
0
0
So a little bit of background, we are trying to use sftpclient to copy a whole directory structure with all files within the directories. It works well with our small sample set of directories and small text files, but when we move on to the real tree with all files (420MB worth) it stops downloading at about 20MB worth.


This is sort of the code we are using - (I'm reconstructing from memory)
Public Sub getFiles(sServer As String, sUsername As String, sPwd As String)
        Dim rSftp As Renci.SshNet.SftpClient
        Dim strPath As String
        strPath="copy_location"
        rSftp = New Renci.SshNet.SftpClient(sServer, sUsername, sPwd)
        rSftp.Connect()
        If(Not System.IO.Directory.Exists(strPath)) Then
            System.IO.Directory.CreateDirectory(strPath)
        End If
        walkSFTPDirs (rSftp.ListDirectory("./tunnel_pack/"), strPath, rSftp)
     rSftp.Disconnect()
End Sub


Public Sub walkSFTPDirs (ByVal dirContent As System.Collections.Generic.IEnumerable(Of renci.SshNet.Sftp.SftpFile), byval strRootPath As String, byval rSftp As Renci.SshNet.SftpClient) 
    Dim dirItm As renci.SshNet.Sftp.SftpFile
    Dim oOutput As System.IO.FileStream

    For Each dirItm In dirContent
        If dirItm.IsDirectory = True Then
            If(Not System.IO.Directory.Exists(strRootPath &  "\\" & dirItm.Name)) Then
                System.IO.Directory.CreateDirectory(strRootPath &  "\\" & dirItm.Name)
                walkSFTPDirs(rsftp.ListDirectory(dirItm.FullName),strRootPath &  "\\" & dirItm.Name, rsftp)
            End If
        Else
            oOutput = New System.IO.FileStream(strRootPath & "\\" & dirItm.Name,System.IO.FileMode.Create)
            rSftp.DownloadFile(dirItm.FullName, oOutput)
            oOutput.Close
        End If
    Next

End Sub
Thanks for any pointers you may provide.
Viewing all 2955 articles
Browse latest View live


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