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

Closed Issue: Issue disconnecting. raising sshconnectionException Client not connected. [1519]

$
0
0
After making a sftp connection, using the function ListDirectory(path), checking IsConnected and if so calling Disconnect() will raise an exception.
Comments: No response, and issue should be fixed by recent commits.

Commented Unassigned: sftpfilestream read is very slow. [1919]

$
0
0
Sftpfile stream is very slow it took 1hr 15 mins for 400mb file.
Is there any way to increase the read buffer of the sftpfilestream.
sftp.buffersize is for upload i believe. But i tried changing it no luck.
Comments: ** Comment from web user: chenthil_it **

Thanks for the response.

If i use sftpclient.downfile which return the memorystream it take around 10 to 15 mins for the same file. But i am running into system.outofmemory in multiple threads of bigger files.

WinSCP also takes around 10 to 15 mins and works fine for bigger files in multiple threads. But i don't want to deploy the winscp.exe in my servers.

Tried manually using filezilla in the same environment download time is around 10 mins.

sftpfilestream looks like the perfect option for the multi thread environment. Because of the transfer speed i am stuck.

Commented Issue: SCP : Missing files when using DirectoryUpload [1382]

$
0
0
Hi,I have the following environment:- Win7 / 64- .NET 3.5- MPC-Target :OpenSSH_6.0p1, OpenSSL 1.0.0j 10 May 2012- SSH.NET commit 19813I want to upload a directory structure (recursive, depth = 2) from the PC to a MPC basedLinux remote system. The total amount of data is about 8MB with 23 files from55 bytes to 4MB.Calling mScp.Upload(new DirectoryInfo(localDir), remoteDir) does not result anyerror and the Uploading event shoes uploading all files. But after Upload() returnedThere are a random number of missing files on the target (between 1 and 5).It tried the same with a PC based Linux as target what resulted in the same behaviour(OpenSSH_5.8p1 Debian-7ubuntu1, OpenSSL 1.0.0e 6 Sep 2011). It seems theproblem is caused anywhere within SSH.NET.Does anyone have a solution?Extension:I tried to workaround by replacing Upload(new DirectoryInfo(...)) by several singlecalls of Upload(new FileInfo(...)). This worked but is too slow for my application.
Comments: ** Comment from web user: Schmid **

Hi drieseng,

I'm pleased to see that one is going to analyze the bug again.
Please let me know if you need any further information or support.

I still need a solution

Thanks
Ulrich

Commented Unassigned: sftpfilestream read is very slow. [1919]

$
0
0
Sftpfile stream is very slow it took 1hr 15 mins for 400mb file.
Is there any way to increase the read buffer of the sftpfilestream.
sftp.buffersize is for upload i believe. But i tried changing it no luck.
Comments: ** Comment from web user: drieseng **

I did some tests myself, and SftpFileStream (SftpClient.OpenRead) is about twice as slow as DownloadFile:
DownloadFile (BufferSize=14000): 2100 Kb/s
DownloadFile (BufferSize=16384): 1500 Kb/s
OpenRead (Buffer=14000): 900 Kb/s
DownloadFile (Buffer=16384): 950 Kb/s

I'm gonna try to look into this later today.
I'll also be reducing logging, as that increases throughput by 100%.

For now, you may want to consider using DownloadFile with a FileStream, and lowering the BufferSize to 14000.

Commented Issue: Unobserved exception rethrown by finalizer thread [1298]

$
0
0
Hi, There is an unhandled System.AggregateException in a worker thread within SSH.NET version 18974 that causes the container application to crash. The exception should be caught and rethrown to the caller. This error occurs when the connection between the SHH client and server is flaky, i.e. it comes on and off. I added an AppDomain unhandled exception handler to log the exception. Here is the stack trace of the exception: ERROR: SubsystemSession.cs(128): Object reference not set to an instance of an object.ERROR: SubsystemSession.cs(169): Renci.SshNet.Sftp.SubsystemSession.Session_ErrorOccured(Object sender, ExceptionEventArgs e) failed.ERROR: System.EventHandler`1.Invoke(Object sender, TEventArgs e) failed.ERROR: Session.cs(1929): Renci.SshNet.Session.RaiseError(Exception exp) failed.ERROR: Session.cs(1592): Renci.SshNet.Session.MessageListener() failed.ERROR: Session.cs(522): Renci.SshNet.Session.b__14() failed.ERROR: System.Threading.Tasks.Task.InnerInvoke() failed.ERROR: System.Threading.Tasks.Task.Execute() failed.ERROR: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.ERROR: Application domain unhandled exception. I am not too familar with Tasks, but I suspect the error could be fixed by adding a catch block to the try block at Session.cs, line 520, and rethrow the exception. I am posting this while I am trying to fix the issue in case someone else can help. Thanks, Robert
Comments: ** Comment from web user: DonPeter **

Hello!
I have the same issue in my win service:

ERROR WCFService.Server.WinService Unhandled exception.
System.NullReferenceException: Object reference not set to an instance of an object.
at Renci.SshNet.Sftp.SubsystemSession.RaiseError(Exception error)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at Renci.SshNet.Session.RaiseError(Exception exp)
at Renci.SshNet.Session.MessageListener()
at Renci.SshNet.Session.<Connect>b__4()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()

Edited Issue: Unobserved exception rethrown by finalizer thread [1298]

$
0
0
Hi, There is an unhandled System.AggregateException in a worker thread within SSH.NET version 18974 that causes the container application to crash. The exception should be caught and rethrown to the caller. This error occurs when the connection between the SHH client and server is flaky, i.e. it comes on and off. I added an AppDomain unhandled exception handler to log the exception. Here is the stack trace of the exception: ERROR: SubsystemSession.cs(128): Object reference not set to an instance of an object.ERROR: SubsystemSession.cs(169): Renci.SshNet.Sftp.SubsystemSession.Session_ErrorOccured(Object sender, ExceptionEventArgs e) failed.ERROR: System.EventHandler`1.Invoke(Object sender, TEventArgs e) failed.ERROR: Session.cs(1929): Renci.SshNet.Session.RaiseError(Exception exp) failed.ERROR: Session.cs(1592): Renci.SshNet.Session.MessageListener() failed.ERROR: Session.cs(522): Renci.SshNet.Session.b__14() failed.ERROR: System.Threading.Tasks.Task.InnerInvoke() failed.ERROR: System.Threading.Tasks.Task.Execute() failed.ERROR: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.ERROR: Application domain unhandled exception. I am not too familar with Tasks, but I suspect the error could be fixed by adding a catch block to the try block at Session.cs, line 520, and rethrow the exception. I am posting this while I am trying to fix the issue in case someone else can help. Thanks, Robert
Comments: ** Comment from web user: drieseng **

I recently fixed this issue (changeset 34793).
Please build from SVN, or wait for the upcoming (beta) release.

Source code checked in, #34838

$
0
0
Avoid race conditions signaling events. Update release notes with new fixes.

Source code checked in, #34839

$
0
0
Large improvement of throughput for DownloadFile by taking into account of the SSH_FXP_DATA header info for determining the length of the data we request in each response message. This eliminates an extra SSH_MSG_CHANNEL_DATA message for each SSH_FXP_DATA.

Commented Unassigned: sftpfilestream read is very slow. [1919]

$
0
0
Sftpfile stream is very slow it took 1hr 15 mins for 400mb file.
Is there any way to increase the read buffer of the sftpfilestream.
sftp.buffersize is for upload i believe. But i tried changing it no luck.
Comments: ** Comment from web user: drieseng **

I've made quite a few changes that improve throughput significantly, but I now also found the reason why SftpFileStream is much slower: we do not take into account the buffer size for SftpFileStream. We always use a buffer size of 4 KB!

I'll fix and test the impact tomorrow.

New Post: Find a remaining disk space in SFTP

$
0
0
Hi,

I'm newcomer for SFTP file transfer.Currently i have created a location as SFTP server in my local machine ( windows 7) . I have developed a project to upload file(s) from local machine to my SFTP server and working successfully. Now i'm looking how to get remaining disk space of SFTP. I have tried to find the disk space by execute a command. But i'm struck with following error

System.ArgumentException was unhandled
HResult=-2147024809
Message=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.
Source=Renci.SshNet
StackTrace:
   at Renci.SshNet.Session.WaitHandle(WaitHandle waitHandle)
   at Renci.SshNet.Channels.Channel.WaitHandle(WaitHandle waitHandle)
   at Renci.SshNet.Channels.ChannelSession.SendExecRequest(String command)
   at Renci.SshNet.SshCommand.BeginExecute(AsyncCallback callback, Object state)
   at LogFileArchive.LogFileArchive.runningcommand() in C:\Utilities\LogFileArchive\Program.cs:line 381
   at LogFileArchive.LogFileArchive.Main(String[] args) in C:\Utilities\LogFileArchive\Program.cs:line 475
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
InnerException:


I was using Renci.Ssh.net dll in my project. please find the code as follows

using (SshClient sshClient = new SshClient("Host", "Port", "Username", "Password"))
{
            sshClient.Connect();
            var cmds = sshClient.RunCommand("echo 1");
            var output = cmds.Result;
}


Please anyone advise is there any other best way or how to run a command

Thanks in advance


with Regards,
Manikandan Gopal

Commented Issue: SCP : Missing files when using DirectoryUpload [1382]

$
0
0
Hi,I have the following environment:- Win7 / 64- .NET 3.5- MPC-Target :OpenSSH_6.0p1, OpenSSL 1.0.0j 10 May 2012- SSH.NET commit 19813I want to upload a directory structure (recursive, depth = 2) from the PC to a MPC basedLinux remote system. The total amount of data is about 8MB with 23 files from55 bytes to 4MB.Calling mScp.Upload(new DirectoryInfo(localDir), remoteDir) does not result anyerror and the Uploading event shoes uploading all files. But after Upload() returnedThere are a random number of missing files on the target (between 1 and 5).It tried the same with a PC based Linux as target what resulted in the same behaviour(OpenSSH_5.8p1 Debian-7ubuntu1, OpenSSL 1.0.0e 6 Sep 2011). It seems theproblem is caused anywhere within SSH.NET.Does anyone have a solution?Extension:I tried to workaround by replacing Upload(new DirectoryInfo(...)) by several singlecalls of Upload(new FileInfo(...)). This worked but is too slow for my application.
Comments: ** Comment from web user: drieseng **

Ulrich,

Please provide a simple repro (code only), and any files necessary to reproduce this issue.

Thanks!
Gert

Commented Unassigned: Need to delete redundant encryptions when using ConnectionInfo [1914]

$
0
0
Need to delete redundant keys in order to communicate with some servers. More than one encryption throws an exception.

foreach (var d in connectionInfo.Encryptions.Where(p => p.Key != "aes256-cbc").ToList())
{
connectionInfo.Encryptions.Remove(d.Key);
}
Comments: ** Comment from web user: drieseng **

Please provide more details. Do you know of a public server that allows us to reproduce this issue?

New Post: telnet

$
0
0
After I SSH onto the server, I would like to telnet onto a specific machine. When I do this through putty, the command I use is "telnet host -l user" and then I am asked to input a password. This is what I currently have:
  using (var ssh = new Renci.SshNet.SshClient(connectionInfo))
        {
            ssh.Connect();
            var cmd = ssh.RunCommand("telnet host -l user");                
        }
The code hangs at the "RunCommand" line, presumably waiting for the password. How do I input the password?

I am new to programming so please be patient.

Thank you in advance!

Created Unassigned: arcfour encryption - Arc4Cipher line 164 - stuck loop on key exchange. [1922]

$
0
0
arcfour - Arc4Cipher.cs line 164
for (byte i = 0; i < STATE_LENGTH; i++)
Where STATE_LENGTH is 256.

Reinitalizes i to 0 (due to i being a byte), causes endless loop on key exchange till server timeout when using arcfour encryption.

New Post: telnet

$
0
0
I was able to get this to work using ShellStream. Here is what I used:
 using (var ssh = new Renci.SshNet.SshClient(connectionInfo))
        {
            ssh.Connect();
            Renci.SshNet.ShellStream stream = ssh.CreateShellStream("xterm", 80, 50, 1024, 1024, 1024);
            StreamReader Reader = new StreamReader(stream);
            StreamWriter Writer = new StreamWriter(stream);
            Writer.AutoFlush = true;
            Thread.Sleep(500);
            string Result = Reader.ReadToEnd();
            Writer.WriteLine("telnet host -l user");
            Thread.Sleep(500);
            Result = Reader.ReadToEnd();
            Writer.WriteLine("password");
            Thread.Sleep(500);
            Result = Reader.ReadToEnd();                
        }

Please let me know if there is a more efficient way.

New Post: ssh conversation

$
0
0
Hi all, I did a deep search about how to make a ssh conversation with this .dll with no luck.

Any of you guys, have a very basic example of how to set a "conversation vis ssh"? Depending of the output at the server, I'll run some commands.

This is for a small project that I'm trying to code. From some windows hosts I want to connect to some unix servers, analyze the ouputs, aunthenticate to the server and finally run some health checks.

Thank you very much.

New Post: Connecting with Password AND Private Key File using SftpClient

$
0
0
Hello, I am using ssh.net lib and it works great for sftpclient connections either with password or privatekeyfile. I have a situation where the host requires a password AND a private key file. What's more they require a certain order during connection - user, key file, password.

I am able to connect to their SFTP site using Filezilla for example, but not using the lib. There is no signature to connect using both.

I understand that this is unusual.

If someone can shed some light on this situation, I would much appreciate it!

thanks,
Dave

New Post: Connecting with Password AND Private Key File using SftpClient

$
0
0
Not sure if it works, but maybe you can use the generic SshClient with ConnectionInfo.
            var coninfo = new ConnectionInfo("1.2.3.4", "peter", new PasswordAuthenticationMethod("peter", "peter"),
                new PrivateKeyAuthenticationMethod("peter", new PrivateKeyFile("foo.key")));
            var client = new SshClient(coninfo);

New Post: Connecting with Password AND Private Key File using SftpClient

$
0
0
Good, thought, I missed that signature. Unfortunately it didn't work... here's the error:
    A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected 
    host has failed to respond ...

New Post: Expect() Not Behaving When Connecting to Cisco Nexus

$
0
0
Hello-

I am using expect to run a command on some Cisco devices. I have found that expect will put all the command output into a string for certain devices and won't for others. For example Expect works with an IOS Router or Catalyst switch. However it doesn't work correctly if one connects to a NXOS(nexus) switch. Basically when connecting to the Nexus device the command output gets lost. It never shows up in the output expect string. I have also not been able to get the information by using read or readline. The latter is true for any Expect connection that I have tried though.

I have two examples of compilable code below that have associated output. Expect1.cs connects to an IOS Router. Expect2.cs connects to a NXOS 3064 switch. If someone thinks I should be able to use read and readline in conjuction with expect please let know how it is supposed to be used. Everything I have tried results in empty strings.

Thanks in Advance.
//Expect1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Renci.SshNet;

//C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe /t:exe /r:C:\Users\ande\Desktop\CSharp\Renci.SshNet.dll Expect1.cs

namespace ExpectTest
{
  class Expect
  {
    static void Main(string[] args)
    {
      string prompt = @".+#$";
      SshClient shell = new SshClient("IOS Router Device or Catalyst IOS", "user", "pass");
      shell.Connect();
      if (shell.IsConnected)
    {
      Console.WriteLine("Connected");
    }
      var stream = shell.CreateShellStream("dumb",80, 24, 800, 600, 1024);
      var a = stream.Expect(new Regex(prompt), new TimeSpan(0, 0, 5));
      Console.WriteLine(a);
      stream.WriteLine("show ip arp");
      var r = stream.Expect(new Regex(prompt), new TimeSpan(0, 0, 5));
      Console.WriteLine(r);
    }
  }
}

/*OUTPUT
C:\Users\ande\Desktop\CSharp>.\Expect1.exe
Connected

NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
Unauthorized access and/or use prohibited. All access and/or use subject to monitoring.
NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE

device-name line 645

3945-Router1#
show ip arp
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  10.5.224.1            162   0000.0c07.acfa  ARPA   GigabitEthernet0/1
Internet  10.5.224.2              3   4403.a7a5.2281  ARPA   GigabitEthernet0/1
Internet  10.5.224.3              0   0006.f619.e8bc  ARPA   GigabitEthernet0/1
Internet  10.5.224.116            -   c067.af42.5f01  ARPA   GigabitEthernet0/1
3945-Router1#
*/
//Expect2.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Renci.SshNet;

//C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe /t:exe /r:C:\Users\ande\Desktop\CSharp\Renci.SshNet.dll Expect2.cs

namespace ExpectTest
{
  class Expect
  {
    static void Main(string[] args)
    {
      //string prompt = @".+#$";
      SshClient shell = new SshClient("NXOS Device", "user", "pass");
      shell.Connect();
      if (shell.IsConnected)
    {
      Console.WriteLine("Connected");
    }
      var stream = shell.CreateShellStream("dumb",80, 24, 800, 600, 1024);
      //var a = stream.Expect(new Regex(prompt), new TimeSpan(0, 0, 5));
      var a = stream.Expect("NX3064_01#", new TimeSpan(0, 0, 5));
      Console.WriteLine(a);
      stream.WriteLine("show ip arp");
      //var r = stream.Expect(new Regex(prompt), new TimeSpan(0, 0, 5));
      var r = stream.Expect("NX3064_01#", new TimeSpan(0, 0, 5));
      Console.WriteLine(r);
    }
  }

//If regular expressions are used for expect, both a and r are empty
//If a regular expression for a is used and a name or regex is used for the second, r stays empty.


/*OUTPUT
C:\Users\ande\Desktop\CSharp>.\Expect2.exe
Connected

Cisco Nexus Operating System (NX-OS) Software
TAC support: http://www.cisco.com/tac
Copyright (c) 2002-2013, Cisco Systems, Inc. All rights reserved.
The copyrights to certain works contained in this software are
owned by other third parties and used and distributed under
license. Certain components of this software are licensed under
the GNU General Public License (GPL) version 2.0 or the GNU
Lesser General Public License (LGPL) Version 2.1. A copy of each
such license is available at
http://www.opensource.org/licenses/gpl-2.0.php and
http://www.opensource.org/licenses/lgpl-2.1.php
NX3064_01#*/
}
Viewing all 2955 articles
Browse latest View live