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

Created Unassigned: Feature request: allow creating an SftpClient from an SshClient instance [2712]

$
0
0
Currently, if I want to use the __same__ SSH session for several purposes - e.g., SFTP and SCP as well as commands I need to instantiate a new _SftpClient_ / _ScpClient_, which means a __new__ SSH connection instead of re-using the existing one. This is not a protocol requirement as SCP and SFTP are merely __channels__ same as the command or shell channel(s), which means that one should be able to create a new instance for SCP / SFTP clients from an existing _SshClient_ instance.

Reviewed: 2014.4.6-beta2 (Jul 23, 2015)

$
0
0
Rated 5 Stars (out of 5) - Very good, thanks!

New Post: SCP Client hangs on Download method call due to password needing changing

$
0
0
We are using the SCP Client to connect to a remote server and download some files. We noticed the process has been hung for the past 3 weeks at the Download method call. We logged into the remote server and noticed that it took us straight to the 'change your password' process.

Is there a way I can detect this situation via SSH.NET prior to attempting to download files? Is there some kind of login object or method I can use which will let me know if I have full access to the account or if we are in some faulty state (like password change)?

Thanks for any guidance.
Karl

Created Unassigned: Bug in SSH shell connection with Cisco IOS [2713]

$
0
0
Hi everyone! So I have compiled the project into a DLL and I am using that to connect to a Cisco server with SSH enabled. Everything works (I am able to issue commands, and the read back is correct), except when you try and issue the "enable" command. When you do this, SSH.net crashes.

For example, here is some sample code (vb.net) used to connect and repeat the issue:

Dim BufferSize as integer = 1024
Dim ssh_client As New SshClient("10.0.0.5", 22, "admin", "cisco")
ssh_client.Connect()
Dim shellstream As ShellStream = ssh_client.CreateShellStream("xterm", 80, 24, 800, 600, BufferSize)
Dim ssh_reader as New IO.BinaryReader(shellstream)
Dim ssh_writer as New IO.BinaryWriter(shellstream)
Do While shellstream.Length = 0
Thread.Sleep(100)
Loop
consoleout = ReadStreamText()
ssh_reader.Read(BufferIn, 0, BufferIn.Length) 'Reads back buffer with ascii "Cisco>"
Dim Data() as byte = System.Text.Encoding.ASCII.GetBytes("enable" & VbCrLf)
ssh_writer.Write(Data, 0, Data.Length)
ssh_writer.Flush()

After the data is sent, the readback buffer is the expected output ("Password:"), but immediately after that, the SSH.net crashes.

Error message: Specified argument was out of the range valid values
Location in SshData.cs:ReadBytes():line 153
The length variable is 29 and the data.count is 5.

After this crash, the shell connection is now unusable, you can not send data or read data from the buffers.

I would also note that this error only happens with the "enable" command. If I issue other commands, they all work and the output is correct. I have tried using SecureCRT and it works perfect as well, so I think there is some kind of bug that happens from data being sent back from the cisco server?

Any ideas?

Created Unassigned: ssh with IPv6 address not working under Linux (help with example?) [2714]

$
0
0
Hallo,

I couldn't figure out how to use your SSH library with an IPv6 address under linux (Ubuntu 15.04),
however it works perfectly fine with an IPv4 address.

my code looks like this:

```
IPAddress ipAddress = IPAddress.Parse ("fe80::XXXX:XXXX:XXXX:XXXX");

SshClient sshClient = new SshClient(ipAddress, user, passwd);
sshClient.Connect();
SshCommand sshCmd = sshClient.RunCommand(command);
sshClient.Disconnect();
```

I hope you can reproduce this issue and/or provide me a code example.

Best regards,
wima

Created Unassigned: DataAvailable false [2715]

$
0
0
I'm trying to tail a fail with using DataReceived callback to get the output.

Unfortunately, DataReceveid is always null. I noticed that DataAvailable is false, so I wonder to what is due this and how I can solve this issue.

shellStream.DataReceived += (sender, dataEvent) =>
{
if (DataReceived != null) // always null !!!
{
string s = shellStream.Read();
if (s != null)
{
Console.WriteLine(s);
}
}
};

shellStream.WriteLine("tail -f foo.log");

New Post: A first chance exception of type 'Renci.SshNet.Common.SshConnectionException

$
0
0
Hi

I'm trying to access and give orders to a Sonicwall Firewall with the SSh.net lib in Visual studio 2012 in C#. I would like to give a simple SSH Order such as" ping 127.0.0.1 "and get the result as an output in to a textbox of a Winforms Application.

Remote System:
firmware-version "SonicOS Enhanced 6.1.1.9-30n"
model "Sonicwall NSA 3600"
My operating System:
Win 8.1
64 bit
.net framework 4

Transfer is just over LAN.


Output in Visual Studio2012 with SShConnectionException:

The thread 'vshost.NotifyLoad' (0x1b6c) has exited with code 0 (0x0).
The thread '<No Name>' (0xf8c) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0x2bb4) has exited with code 0 (0x0).
'SSH Testclient.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\tman\Documents\Visual Studio 2012\Projects\SSH Testclient\SSH Testclient\bin\Debug\SSH Testclient.exe', Symbols loaded.
'SSH Testclient.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
SshNet.Logging Verbose: 1 : Initiating connect to '...'.
SshNet.Logging Verbose: 1 : Server version '2.0' on 'OpenSSH_5.8'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'KeyExchangeInitMessage': 'SSH_MSG_KEXINIT'.
'SSH Testclient.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Dynamic\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Dynamic.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'SSH Testclient.vshost.exe' (Managed (v4.0.30319)): Loaded 'Anonymously Hosted DynamicMethods Assembly'
SshNet.Logging Verbose: 1 : SendMessage to server 'KeyExchangeInitMessage': 'SSH_MSG_KEXINIT'.
SshNet.Logging Verbose: 1 : SendMessage to server 'KeyExchangeDhGroupExchangeRequest': 'SSH_MSG_KEX_DH_GEX_REQUEST'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'KeyExchangeDhGroupExchangeGroup': 'SSH_MSG_KEX_DH_GEX_GROUP'.
SshNet.Logging Verbose: 1 : SendMessage to server 'KeyExchangeDhGroupExchangeInit': 'SSH_MSG_KEX_DH_GEX_INIT'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'KeyExchangeDhGroupExchangeReply': 'SSH_MSG_KEX_DH_GEX_REPLY'.
SshNet.Logging Verbose: 1 : SendMessage to server 'NewKeysMessage': 'SSH_MSG_NEWKEYS'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'NewKeysMessage': 'SSH_MSG_NEWKEYS'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ServiceRequestMessage': 'SSH_MSG_SERVICE_REQUEST'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ServiceAcceptMessage': 'SSH_MSG_SERVICE_ACCEPT'.
SshNet.Logging Verbose: 1 : SendMessage to server 'RequestMessageNone': 'SSH_MSG_USERAUTH_REQUEST'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'SuccessMessage': 'SSH_MSG_USERAUTH_SUCCESS'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelOpenMessage': 'SSH_MSG_CHANNEL_OPEN : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelOpenConfirmationMessage': 'SSH_MSG_CHANNEL_OPEN_CONFIRMATION : #0'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelRequestMessage': 'SSH_MSG_CHANNEL_REQUEST : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelSuccessMessage': 'SSH_MSG_CHANNEL_SUCCESS : #0'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelRequestMessage': 'SSH_MSG_CHANNEL_REQUEST : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelWindowAdjustMessage': 'SSH_MSG_CHANNEL_WINDOW_ADJUST : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelSuccessMessage': 'SSH_MSG_CHANNEL_SUCCESS : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.

Copyright (c) 2012 Dell | SonicWALL, Inc.

Using username 'User'.
Password:
SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.
SshNet.Logging Verbose: 1 : ReceiveMessage from server: 'ChannelDataMessage': 'SSH_MSG_CHANNEL_DATA : #0'.

SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelEofMessage': 'SSH_MSG_CHANNEL_EOF : #0'.
SshNet.Logging Verbose: 1 : SendMessage to server 'ChannelCloseMessage': 'SSH_MSG_CHANNEL_CLOSE : #0'.
SshNet.Logging Verbose: 1 : SendMessage to server 'DisconnectMessage': 'SSH_MSG_DISCONNECT'.
A first chance exception of type 'Renci.SshNet.Common.SshConnectionException' occurred in SSH Testclient.exe
The thread '<No Name>' (0xe80) has exited with code 0 (0x0).

Code:
Image
Image
Image

I think the Exception must be the Problem. but i cant figure out a solution and havent found a similar case.

Ty for your replies.
T.

New Post: How access SonicWALL

$
0
0
Do you have a solution? I have the same problem....

Best regards,

Stefan

New Post: How access SonicWALL

$
0
0
I have a similar Problem but no solution yet.

Best Regards

Tom

New Post: Exit code from remote linux bash execution

$
0
0
Hello:

A bash shell script executes code and then echoes text and the screen and exits with a specific exit code like:

echo "This is my text"
exit 1

RunCommand captures the string "This is my text". How do I capture the exit code of 1?

Thanks

New Post: How access SonicWALL

New Post: SSH.Net log network data throw proxy

$
0
0
Here is my code wich is use for login into a ssh server and foward port success
SshClient client;
ForwardedPortDynamic port;

publicvoid Start(string server, string user, string password, int serverport=22)
{
        client = new SshClient(server, user, password);
        client.KeepAliveInterval = new TimeSpan(0, 0, 5);
        client.ConnectionInfo.Timeout = new TimeSpan(0, 0, 20);
        client.Connect();

        if (client.IsConnected)
        {
            try
            {
                port = new ForwardedPortDynamic("127.0.0.1", 1080);
                client.AddForwardedPort(port);
                port.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

}

publicvoid Stop()
{
    port.Stop();
    port.Dispose();
    client.Disconnect();
    client.Dispose();
}
On my Firefox browser I have added "127.0.0.1", 1080 into proxy setting and I can access website under this proxy, as a result, I want to write every network data going throw this proxy when I using proxy to a textbox but I don't know how to get log connection data. Is it like this port.ConnectionLog?

And the data I will received look like
Firefox.exe connecting to http://google.com..
Firefox.exe packet received first bye 22136...
....
Thanks in advanced

New Post: SSH.Net log network data throw proxy

Reviewed: 2014.4.6-beta2 (Aug 20, 2015)

$
0
0
Rated 5 Stars (out of 5) - Its a good library with examples. Thanks a lot. :)

New Post: Screen limitation on return command

$
0
0
I am sending a command for a mikrotik by ssh.
/interface print stats
  I'm getting this output.
  13 DR <pppo ... 111 749 511 1 216 396 589 1 054 678 1 074 122
DR 14 <pppo ... 49 965 132 1 184 225 860 605 504 916 373
15 DR <pppo ... 66 667 81110420341
16 DR <pppo ... 29 791 984 243 315 464 240 787 246 964
DR 17 <pppo ... 301 669 126 4 026 202 133 3 773 889 4 139 573
Correct the output is
> 13 DR <pppoe-user1> 111 749 511 1 216 396 589 1 054 678 1 074 122
14 DR <pppoe-user2> 49 965 132 1 184 225 860 605 504 916 373
15 DR <pppoe-user3> 66 667 81110420341
16 DR <pppoe-user4> 29 791 984 243 315 464 240 787 246 964
DR 17 <pppoe-user5> 301 669 126 4 026 202 133 3 773 889 4 139 573
It is cutting the name of the User. It is to change the size of output. Screen appears limitation on the return command.

New Post: How can I enable the receipt of 8 bit characters from a SSH connection

$
0
0
Hi,

I have been most impressed with SSH.NET, with all the help here I was able to get my terminal emulator to make SSH connections in a short period of time. Well done.

My current issue I have not been able to yet solve. The server program outputs terminal control characters in the range 0x80 to 0xFF. I have tried setting terminal modes in the call to CreateShellStream and I have tried all of the Encoding values in the call to StreamReader constructor. In all cases some if not all of the characters 0x80-0xFF were translated.

Please see my code snippet below.

Regards,
Dave.
                    System.Collections.Generic.Dictionary<TerminalModes, uint> tm = new System.Collections.Generic.Dictionary<TerminalModes, uint>();
                    tm[TerminalModes.PARENB] = 0;
                    tm[TerminalModes.ISTRIP] = 0;
                    tm[TerminalModes.CS7] = 0;
                    tm[TerminalModes.CS8] = 1;

                    /* Start the monitor thread which will detect when remote end
                     * closes the connection and will invoke DisconnectEx on this
                     * connection thread */

                    DisconnectEvent += new DisconnectEventHandler(Disconnect);
                    monitorThread = new Thread(monitor);
                    monitorThread.Start();

                    strm = client.CreateShellStream(termType, (uint)tw.Columns, (uint)tw.Rows,
                                                    (uint)tw.ClientSizeEx.Width, (uint)tw.ClientSizeEx.Height, 1024, tm);

if ISNT

                    strm = client.CreateShellStream(termType, (uint)tw.Columns, (uint)tw.Rows,
                                                    (uint)tw.ClientSizeEx.Width, (uint)tw.ClientSizeEx.Height, 1024);

endif

                    //strmReader = new StreamReader(strm);
                    /* Tried these encodings:-
                     * ASCII - >= 0x80-0xFF translated to 0x3F.
                     * Default - 0x80-0x9F : Some set of special Unicode characters, 0xA0-0xFF : unchanged.
                     *           This is using the current Windows ANSI code page. Do I need something like
                     *           code page 8859-1 - Latin alphabet which doesn't seem to translate codes.
                     * Unicode - got a buffer of individual bytes instead of normal 0x61 0x00 etc for each char.
                     * UTF8 - I think this is default. >= 0x80 translated to 0xfffd
                     */ 
                    strmReader = new StreamReader(strm, Encoding.Default);
                    //strmWriter = new StreamWriter(strm);
                    strmWriter = new StreamWriter(strm, Encoding.Default);

New Post: X11 forward

$
0
0
Hi
Is it possible to forward X11 using ssh.net as client?
I installed xming in my windows and want to run GUI app of linux in my windows client using C# and ssh.net.
Any idea?

Patch Uploaded: #17796

$
0
0

cmn has uploaded a patch.

Description:
Allow sending data to a process' stdin.

When using SSH as a connection and authentication layer to talk to a program on a remote host, you may need to talk to it, rather than just execute it and wait for its output.

This patch adds a write-only stream to SshCommand which lets you write into it and will immediately send the data to the process' stdin.

New Post: How can I enable the receipt of 8 bit characters from a SSH connection

$
0
0
I have solved this problem by supplying an instantiation of my own Encode class, very similar to the the ASCIIEncoding class in Renci.SshNet. It overrides various methods so that bytes are passed through unchanged. I did also get things working by removing the StreamReader/Writers and just using strm.Read and Write, the ConnectionInfo passed in the creation of 'client' needed connectionInfo.Encoding to be set to my encode class.

Dave.

New Post: SSH.NET Licence Agreement in comercial application

$
0
0
Can I use SSH.NET DLLs in project for application development for my customer.

Is there any restriction in this case? I read Licence agreement under Licence tab but I am not sure that this component is free in the case when I want to reference dlls in my Visual studio project and use methods for accessing files on SFTP server.
Viewing all 2955 articles
Browse latest View live


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