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

New Post: Remote MD5 checksum on ftp server?

$
0
0
Simply run a md5 command on the file on the server and read the result.
Compare the result with your expected (local?) value.

Commented Unassigned: Problems with IPSwitch MoveIt SSH server [1785]

$
0
0
Has anyone had problems when using the code with IPSwitch MoveIt ?

I can connect OK, list files, rename, upload & download. But when I try to delete a file I get "permission denied".
Although if I connect to the MoveIt server with Filezilla client I can delete the file, so it's not a permissions issue.
And my code is fine because I can delete files no problem from UNIX & LINUX servers.
It has a similar problem when I try to overwrite an existing file.

Any help would be appreciated.

Cheers

Phil
Comments: ** Comment from web user: sergioesp **

Same issue here.

Created Unassigned: Timeout on proxy authentication [1905]

$
0
0
You have neverending loo while authentication through proxy


```
Session.cs

while (true)
{
...

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

This break end switch but not while loop.
Fastest way is just to replace "break" with "return"
Please fix It.
Can I do smt to make this request faster?
If

New Comment on "Documentation"

$
0
0
A note about the CHM file. If you install this on a file share and you cannot see the html in the right window, you may have issues with UNC paths. Install this on your local hard drive and see if the links will now open. I still could not see the hmtl in the right window after doing the Unblock (Win 7). I found some info related to UNC path issues. Copied to my C: drive and now I can see all the html pages.

New Post: Commands

$
0
0
Hi,

I have some issues using this library. First, some commands are not executed on SSH server machine. For e.g. ls work ok, but cd /home doesn't work.

Second thing scares me most. How can send key press event? OK, I can send command, but I need to for e.g. execute command to open application and send press key event like Escape or Ctrl + X etc...

Commented Unassigned: Problems with IPSwitch MoveIt SSH server [1785]

$
0
0
Has anyone had problems when using the code with IPSwitch MoveIt ?

I can connect OK, list files, rename, upload & download. But when I try to delete a file I get "permission denied".
Although if I connect to the MoveIt server with Filezilla client I can delete the file, so it's not a permissions issue.
And my code is fine because I can delete files no problem from UNIX & LINUX servers.
It has a similar problem when I try to overwrite an existing file.

Any help would be appreciated.

Cheers

Phil
Comments: ** Comment from web user: drieseng **

Are you all having this issue in combination with IPSwitch MoveIt ?
Do you know of a public server we can test against ?

Commented Unassigned: Problems with IPSwitch MoveIt SSH server [1785]

$
0
0
Has anyone had problems when using the code with IPSwitch MoveIt ?

I can connect OK, list files, rename, upload & download. But when I try to delete a file I get "permission denied".
Although if I connect to the MoveIt server with Filezilla client I can delete the file, so it's not a permissions issue.
And my code is fine because I can delete files no problem from UNIX & LINUX servers.
It has a similar problem when I try to overwrite an existing file.

Any help would be appreciated.

Cheers

Phil
Comments: ** Comment from web user: IdidWhat **

Mine turned out to be a permission setting in MoveIT. I talked to our MoveIT admin and they changed a permission for the folder I was using.

Commented Issue: Timeout on proxy authentication [1905]

$
0
0
You have neverending loo while authentication through proxy


```
Session.cs

while (true)
{
...

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

This break end switch but not while loop.
Fastest way is just to replace "break" with "return"
Please fix It.
Can I do smt to make this request faster?
Comments: ** Comment from web user: drieseng **

This is a duplicate of https://sshnet.codeplex.com/workitem/1890.
The fix is trivial, but I first want to increase test coverage as this issue show it surely lacks in this area.


Commented Issue: HTTP proxy hangs [1890]

$
0
0
When connecting to an http proxy the Session.ConnectHttp() method gets stuck in an endless loop.

this is due to the following code::

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

which should be

switch (statusCode)
{
case HttpStatusCode.OK:
return_;
default:
throw new ProxyException(string.Format("HTTP: Status code {0}, \"{1}\"", statusCode, statusCode));
}
Comments: ** Comment from web user: drieseng **

The fix is trivial, but I first want to increase test coverage as this issue show it surely lacks in this area.

Commented Unassigned: Incorrect handling of SocketException in Session.ReadSocket() [1885]

$
0
0
In SocketRead() in Session.NET.cs there's a dubious handling of SocketExceptions. This is what the original code looked like:
```
catch (SocketException exp)
{
if (exp.SocketErrorCode == SocketError.ConnectionAborted)
{
buffer = new byte[length];
this.Disconnect();
return;
}
... // Code removed for brevity
else
throw; // any serious error occurred
}
```
It would seem that the code tries to figure out if "our side" did the disconnect, and then it would send a disconnect message to server, and be done. The problem is that this exception also signals if all sides of the socket is closed. If you use TcpView (sys internals tool) to forcibly close the connection, Disconnect() will be called, and the thread terminates, leaving pending operations such as RunCommand() hanging.

My fix solves *my* particular problem, but I am not sure what impact it has on the rest of the software. This is what I added:
```
catch (SocketException exp)
{
if (this._socket.Connected && // Check if we're still connected
exp.SocketErrorCode == SocketError.ConnectionAborted)
{
buffer = new byte[length];
this.Disconnect();
return;
}
else if (exp.SocketErrorCode == SocketError.WouldBlock ||
exp.SocketErrorCode == SocketError.IOPending ||
exp.SocketErrorCode == SocketError.NoBufferSpaceAvailable)
{
// socket buffer is probably empty, wait and try again
Thread.Sleep(30);
}
else
throw; // any serious error occurred
}
```

The logic is that "If we're not connected anymore via the socket, then something bad happened, and we want outstanding requests to know". The thread of execution will reach the rethrow, which in turn will activate the RaiseError() method further up the stack.
Comments: ** Comment from web user: Euan **

In all the exceptions I have seen here _socket is null, so it does not fix anything.

New Post: Check if Directory exists with SSH.NET

$
0
0
Hello,

I'm wondering if anyone knows how to check if a directory exists with SSH.NET. I tried using the Exists function with sFtpClient class, however this function didn't work.

Thanks!
Jason

New Post: Commands

$
0
0
I bet the "cd /home" works. You have to keep in mind that every RunCommand() has a new "shell".
If you want to run commands together in one context you have to create/manage your own shell or combine them with "&&" or "||".

e.g.: RunCommand("cd /home/ && pwd");

Created Unassigned: Timeout on Uploading file [1906]

$
0
0
Hi All,

I've tried to search for this issue but haven't had any luck.

I am trying to upload a file to an SFTP but it fails when the file is larger than approx 50kb, when the file is smaller than that it works flawlessly.

It seems to be failing on;

this.SendRequest(request);

And something to do with;

this._session.WaitHandle(waitHandle);.

The exception is;
at Renci.SshNet.Session.WaitHandle(WaitHandle waitHandle) in C:\Devel\InternalApplications\Renci.SshNet\Session.cs:line 643
at Renci.SshNet.Channels.Channel.WaitHandle(WaitHandle waitHandle) in C:\Devel\InternalApplications\Renci.SshNet\Channels\Channel.cs:line 496
at Renci.SshNet.Channels.Channel.SendMessage(ChannelDataMessage message) in C:\Devel\InternalApplications\Renci.SshNet\Channels\Channel.cs:line 446
at Renci.SshNet.Channels.Channel.SendData(Byte[] buffer) in C:\Devel\InternalApplications\Renci.SshNet\Channels\Channel.cs:line 215
at Renci.SshNet.Sftp.SubsystemSession.SendData(Byte[] data) in C:\Devel\InternalApplications\Renci.SshNet\SubsystemSession.cs:line 115
at Renci.SshNet.Sftp.SftpSession.SendMessage(SftpMessage sftpMessage) in C:\Devel\InternalApplications\Renci.SshNet\Sftp\SftpSession.cs:line 86
at Renci.SshNet.Sftp.SftpSession.SendRequest(SftpRequest request) in C:\Devel\InternalApplications\Renci.SshNet\Sftp\SftpSession.cs:line 251

Please could you let me know how I can resolve this?

Many thanks,

David

Commented Unassigned: Timeout on Uploading file [1906]

$
0
0
Hi All,

I've tried to search for this issue but haven't had any luck.

I am trying to upload a file to an SFTP but it fails when the file is larger than approx 50kb, when the file is smaller than that it works flawlessly.

It seems to be failing on;

this.SendRequest(request);

And something to do with;

this._session.WaitHandle(waitHandle);.

The exception is;
at Renci.SshNet.Session.WaitHandle(WaitHandle waitHandle) in C:\Devel\InternalApplications\Renci.SshNet\Session.cs:line 643
at Renci.SshNet.Channels.Channel.WaitHandle(WaitHandle waitHandle) in C:\Devel\InternalApplications\Renci.SshNet\Channels\Channel.cs:line 496
at Renci.SshNet.Channels.Channel.SendMessage(ChannelDataMessage message) in C:\Devel\InternalApplications\Renci.SshNet\Channels\Channel.cs:line 446
at Renci.SshNet.Channels.Channel.SendData(Byte[] buffer) in C:\Devel\InternalApplications\Renci.SshNet\Channels\Channel.cs:line 215
at Renci.SshNet.Sftp.SubsystemSession.SendData(Byte[] data) in C:\Devel\InternalApplications\Renci.SshNet\SubsystemSession.cs:line 115
at Renci.SshNet.Sftp.SftpSession.SendMessage(SftpMessage sftpMessage) in C:\Devel\InternalApplications\Renci.SshNet\Sftp\SftpSession.cs:line 86
at Renci.SshNet.Sftp.SftpSession.SendRequest(SftpRequest request) in C:\Devel\InternalApplications\Renci.SshNet\Sftp\SftpSession.cs:line 251

Please could you let me know how I can resolve this?

Many thanks,

David
Comments: ** Comment from web user: davidjohnson84 **

Resolved: Reduced buffer size to 15000. Anything larger than this wouldn't work.

sftp.BufferSize = 15000;

Thanks,

Dave

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

The infinite loop was fixed by Oleg in changeset #28762, but there are still some issues left to fix.
I'll leave this issue open until I have a new version of ssh.net available that you can test.


Source code checked in, #34706

$
0
0
Skip headers (and message body if Content-Length headers is set) returned by HTTP proxy. Fail fast when proxy does not return HTTP 200. Added corresponding regression tests. Fixes the following issues: 1601, 1890 and 1905.

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

Fixed in changeset 34706.
I'll talk to Oleg about the possibility to release a new version of SSH.NET.

Edited Issue: HTTP proxy hangs [1890]

$
0
0
When connecting to an http proxy the Session.ConnectHttp() method gets stuck in an endless loop.

this is due to the following code::

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

which should be

switch (statusCode)
{
case HttpStatusCode.OK:
return_;
default:
throw new ProxyException(string.Format("HTTP: Status code {0}, \"{1}\"", statusCode, statusCode));
}
Comments: ** Comment from web user: drieseng **

Fixed in changeset 34706.
I'll talk to Oleg about the possibility to release a new version of SSH.NET.

Edited Issue: Timeout on proxy authentication [1905]

$
0
0
You have neverending loo while authentication through proxy


```
Session.cs

while (true)
{
...

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

This break end switch but not while loop.
Fastest way is just to replace "break" with "return"
Please fix It.
Can I do smt to make this request faster?
Comments: ** Comment from web user: drieseng **

Fixed in changeset 34706.
I'll talk to Oleg about the possibility to release a new version of SSH.NET.

Closed Unassigned: Closing forwarded ports does not work [1867]

$
0
0
Dear all,

I use PuTTy with the following settings for port forwarding which works fine:
putty.exe -ssh user@hostname -L 5555:localhost:5555 -L 5554:localhost:5554 -N -pw password


Now I want to do this from C# and therefore I'd like to use the SSH.NET library. So I use the following to forward the ports:
```
public void ForwardPortLocally(uint portNumber)
{
try
{
var p = new ForwardedPortLocal("localhost", portNumber, "localhost", portNumber);
client.AddForwardedPort(p);
p.Start();
}
catch (Exception ex)
{
throw new Exception(String.Format("ERROR: Port forwarding failed: {0}", ex.Message));
}
}
```
I know I need to clean up after my self an therefore I use the following code:
```
public void Dispose()
{
var toDispose = new List<ForwardedPortLocal>();
foreach (var forwardedPort in client.ForwardedPorts.Where(forwardedPort => forwardedPort.IsStarted))
{
forwardedPort.Stop();
toDispose.Add((ForwardedPortLocal)forwardedPort);
}
foreach (var port in toDispose)
{
client.RemoveForwardedPort(port);
port.Dispose();
}
if (client.IsConnected)
{
client.Disconnect();
}
client.Dispose();
}
```
This is where the problem begins. I am not able to close my ports properly. While setting up the forwarded ports is working fine, the attempt to close it always fails.
Once I have setup the forwarded ports and closed the application I am not able to open them anymore because they are still in use and I get the exception:
> "Only one usage of each socket address (protocol/network address/port) is normally permitted"

I have used sysinternals' tcpview to see whether the ports stay open and they do but the process is "non-existent". I have to logg off and on again from Windows to be able to re-open the port.

Am I doing something wrong? Have I found a bug in the library?

Regards


P.S.: I also experienced that the method i use to get rid of the forwarded ports takes seconds to run which is very long and seems a bit odd to me.
Comments: Issues fix in client code, not in SSH.NET.
Viewing all 2955 articles
Browse latest View live


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