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

Commented Unassigned: SftpClient.WriteAllText saving wrong text. [1783]

$
0
0
I am using SshNet to update a text file on a Raspberry Pi server, running Raspbian. The server is running vsftpd as the FTP server.

The user modifies some text in the application (which was downloaded using the ReadAllText method) and then clicks save, which should save the edited text in the specified file on the server, using the WriteAllText method.

The problem is that the text somehow gets corrupted by using the WriteAllText method. Here is what I observed:

- If trying to edit somewhere around the middle of the text, it saves the text fine.
- If trying to add text to the end, it works fine.
- If trying to delete text from the end, all hell breaks loose. Example, editing the end of a text file:

Before deleting:
"Kind regards,


Department management"

After deleting everything after "Kind regards," and saving, this is what gets saved:
"Kind regards,
Department management"

- If trying to replace text at the end:

Replacing "Department management" with "Senior management":

"Kind regards,

Senior managementt" [Notice the double t at the end, it was not a typo. For different text, worse things that a double t appear.]

I have managed to work around it by saving the text to a file in the temp path and uploading it using the UploadFile method, which seems to be working fine.

I have attached the adapter I use for this (stripped of the stuff irrelevant to this problem).
Comments: ** Comment from web user: drieseng **

The problem is that - in SftpClient.WriteAllText (and all other WriteAll* methods) - we use SftpClient.CreateText which does not truncate the files if it already exists.

I thnik we should modify SftpClient.CreateText to use SftpClient.Create instead of SftpClient.OpenWrite. This will cause the file to be truncated if it already exists.

I also would propose to modify SftpClient.OpenWrite to open the remote file in append mode.
It does not make sense to start writing to the beginning of a file if you do not truncate it first, as that would leave part of the original file there if the new content contains less characters than the content of the existing file.


Created Issue: IsConnected returns true when sshd has closed connection or network is not available [1898]

$
0
0
Currently, The IsConnection property (on BaseClient) returns true even when:
* the server has shut down the ssh connection

To reproduce:

1. Create a connection (eg using SftpClient)
2. Kill sshd process on server.
3. Inspect value of IsConnected property.

* the network is no longer available

To reproduce:

1. Create a connection (eg using SftpClient)
2. Unplug network cable
3. Inspect value of IsConnected property.

I can reproduce this with ssh.net built from SVN/TFS.

Commented Issue: IsConnected returns true when sshd has closed connection or network is not available [1898]

$
0
0
Currently, The IsConnection property (on BaseClient) returns true even when:
*** the server has shut down the ssh connection

To reproduce:

1. Create a connection (eg using SftpClient)
2. Kill sshd process on server.
3. Inspect value of IsConnected property.

*** the network is no longer available

To reproduce:

1. Create a connection (eg using SftpClient)
2. Unplug network cable
3. Inspect value of IsConnected property.

I can reproduce this with ssh.net built from SVN/TFS.
Comments: ** Comment from web user: drieseng **

The fact that IsConnected returns true in the above cases also causes issues when disconnecting or disposing the client.

For example:
https://sshnet.codeplex.com/workitem/1581

Note that I have yet to find an easy way to tell whether the connection is in one of the states mentioned above. Socket.Poll does not offer a solution, and neither does Socket.Send with a empty buffer.

The Socket.Connected property only allows you to check whether a socket is NOT connected. If it returns false, you can be sure that the connection is closed (or not yet opened). When it returns true, you only know that the last operation was succesful.

Even sending an "IgnoreMessage" is considered successful while the network cable is unplugged.
From the MSDN docs:

"There is also no guarantee that the data you send will appear on the network immediately. To increase network efficiency, the underlying system may delay transmission until a significant amount of out-going data is collected. A successful completion of the Send method means that the underlying system has had room to buffer your data for a network send."

New Post: Slow Performance .... help!!

$
0
0
As mentioned in my previous post. "I am connecting via sftp and only getting about 100KB instead of 1,000KB"

New Post: Slow Performance .... help!!

$
0
0
jhoop2002 wrote:
As mentioned in my previous post. "I am connecting via sftp and only getting about 100KB instead of 1,000KB"
whao...

You want help? Then give us your code where you measure the performance and some more useful information.
Else... i'm out...

New Post: PortForwading Bug

$
0
0
Hi!

Thanks a lot!!

It seems run ok with the ClearPool. I have the doubt why Chilkat component don't need the Clearpool, can be they do it inside the DLL.

Thanks for your time.

New Post: VB.net upload

$
0
0
Can anyone provide a simple sample for uploading 1 file to a directory using sftp? I have found several c# samples, but that work for me in vb.net.

Thanks!

Commented Issue: GlobalRequestMessage bug [1295]

$
0
0
Version 17229, file \Messages\Connection\GlobalRequestMessage.cs, line 86: Should the default switch case be a return instead of a break?
 
I am receiving a "keepalive@openssh.com" message which results in:
 
System.ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.List`1.CopyTo(Int32 index, T[] array, Int32 arrayIndex, Int32 count)
at Renci.SshNet.Common.SshData.ReadBytes(Int32 length) in SshData.cs: line 155
at Renci.SshNet.Common.SshData.ReadUInt32() in SshData.cs: line 194
at Renci.SshNet.Common.SshData.ReadString() in SshData.cs: line 239
at Renci.SshNet.Messages.Connection.GlobalRequestMessage.LoadData() in GlobalRequestMessage.cs: line 90
at Renci.SshNet.Common.SshData.Load(Byte[] value) in SshData.cs: line 91
at Renci.SshNet.Session.LoadMessage(Byte[] data) in Session.cs: line 1549
at Renci.SshNet.Session.ReceiveMessage() in Session.cs: line 882
at Renci.SshNet.Session.MessageListener() in Session.cs: line 1589
 
 
Possibly related to http://sshnet.codeplex.com/discussions/346993
Comments: ** Comment from web user: kayhanyuksel **

Hi , I am getting the same errors, I have tried to check the version of the dll from file properties but couldn't.
Probably, the one I have downloaded is a newer one than the one mentioned but still got that error.


Commented Issue: GlobalRequestMessage bug [1295]

$
0
0
Version 17229, file \Messages\Connection\GlobalRequestMessage.cs, line 86: Should the default switch case be a return instead of a break?
 
I am receiving a "keepalive@openssh.com" message which results in:
 
System.ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.List`1.CopyTo(Int32 index, T[] array, Int32 arrayIndex, Int32 count)
at Renci.SshNet.Common.SshData.ReadBytes(Int32 length) in SshData.cs: line 155
at Renci.SshNet.Common.SshData.ReadUInt32() in SshData.cs: line 194
at Renci.SshNet.Common.SshData.ReadString() in SshData.cs: line 239
at Renci.SshNet.Messages.Connection.GlobalRequestMessage.LoadData() in GlobalRequestMessage.cs: line 90
at Renci.SshNet.Common.SshData.Load(Byte[] value) in SshData.cs: line 91
at Renci.SshNet.Session.LoadMessage(Byte[] data) in Session.cs: line 1549
at Renci.SshNet.Session.ReceiveMessage() in Session.cs: line 882
at Renci.SshNet.Session.MessageListener() in Session.cs: line 1589
 
 
Possibly related to http://sshnet.codeplex.com/discussions/346993
Comments: ** Comment from web user: kayhanyuksel **

************** Exception Text **************
System.ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
at Renci.SshNet.SshCommand.WaitHandle(WaitHandle waitHandle)
at Renci.SshNet.SshCommand.EndExecute(IAsyncResult asyncResult)
at sqllivegui.Form1.DoExecuteParallel(Dictionary`2 TargetSites, String schema, String _postParameters) in c:\Projects\xxxx\sqllivegui\Form1.cs:line 777
at sqllivegui.Form1.flowMultiple(Dictionary`2 _dctTargetSites, String _schema) in c:\Projects\xxxx\sqllivegui\Form1.cs:line 484
at sqllivegui.Form1.flowcontrol() in c:\Projects\xxxx\sqllivegui\Form1.cs:line 350
at sqllivegui.Form1.button1_Click(Object sender, EventArgs e) in c:\Projects\xxxx\sqllivegui\Form1.cs:line 312
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

New Post: Connect to linux server by SSH.NET library

$
0
0
Hi,

I'm new user of SSH.NET, I have some questions on it.
  1. How can I su my account by runcommand or runshell? I know it's an old question, but I didn't find a worked solution for me on the internet. Could you help?
  2. I'd like to execute a script on linux server, I have a sample code as below.
var ssh = new SshClient("ip", "user", "password");
var cmd = ssh .CreateCommand("./executescript");
cmd.BeginExecute();
var reader = new StreamReader(cmd.OutputStream);
var result = reader.ReadToEnd();

but I can't finish executing the script because it will ask a question like 'would you like to do that? yes or no', how can I send yes or no during executing the scripts?

Commented Unassigned: System.OutOfMemoryException when trying large files in sftp [1866]

$
0
0
Exception of type 'System.OutOfMemoryException' was thrown.
mscorlib
at System.IO.MemoryStream.set_Capacity(Int32 value)
at System.IO.MemoryStream.EnsureCapacity(Int32 value)
at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)

-------
Multiple files of 400MB or 1GB files.
The entire file is in the stream object that could be the problem.
--------
Comments: ** Comment from web user: drieseng **

Please use a FileStream instead.

Edited Unassigned: System.OutOfMemoryException when trying large files in sftp [1866]

$
0
0
Exception of type 'System.OutOfMemoryException' was thrown.
mscorlib
at System.IO.MemoryStream.set_Capacity(Int32 value)
at System.IO.MemoryStream.EnsureCapacity(Int32 value)
at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)

-------
Multiple files of 400MB or 1GB files.
The entire file is in the stream object that could be the problem.
--------
Comments: ** Comment from web user: drieseng **

Let us know if we can close this issue.

Source code checked in, #34612

$
0
0
Correct casing of Security/Cryptography/HMAC.cs. Fixes issue #1505.

Edited Issue: Correct casing of Security/Cryptography/HMAC.cs [1505]

$
0
0
I've just tried to compile the library on Mono/Linux, it builds, however with one glitch. The mentioned file is named HMAC.cs, but is referenced as Security/Cryptography/HMac.cs, so either reference or the file should be changed to both to be consistent. Otherwise builds and works fine, thanks for the lib.
Comments: ** Comment from web user: drieseng **

Fixed in changeset 34612.
Thanks for the report!

New Post: Format output in ssh.net library

$
0
0
Where exactly do you change the format for the result. I'm outputting SSH from Cisco IOS and its all coming out bunched up and all on one line. Would anyone have any advice on the best way to format/wrap the output from a switch.

New Post: Remote MD5 checksum on ftp server?

$
0
0
Hi, i want to ask, SSH.NET allow to check MD5 on server after program upload it from local ? Or for this moment its impossible or there some other ways?

New Post: Run command unblocking

$
0
0
Hi,
I am using ssh.net library to run the following command in a Linux box that executes commands to another system:
bash -l -c '/usr/local/bin/runTest ip user pass Test_Case 1'

However, I would want to run the command in a non-blocking mode.

I tried adding a & at the end and it has the opposite effect since it keeps the bash command open.

Any ideas on how to achieve this?
Thanks.

New Post: FileZilla and WINSCP is able to connect and list the folders but Tamir DLL is unable to list the files‏

$
0
0
Hi Support,
I need help regarding the issue I am getting to get the files from the folder by using Tamir DLL in .NET console application/window service. The error is :
Tamir.SharpSsh.jsch.SftpException: Exception of type 'Tamir.SharpSsh.jsch.SftpException' was thrown.
at Tamir.SharpSsh.jsch.ChannelSftp.ls(String path)
at Tamir.SharpSsh.Sftp.GetFileList(String path)
I am able to connect SFTP using FileZilla and WinSCP, so I believe rights are proper on the folder, what can the issue be?

New Post: FileZilla and WINSCP is able to connect and list the folders but Tamir DLL is unable to list the files‏

$
0
0
Wrong Project? This is SSH.NET not Tamir.SharpSsh, sry.

New Post: Run command unblocking

$
0
0
SshCommand supports Async execution with BeginExecute().
Viewing all 2955 articles
Browse latest View live


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