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

New Post: Simple input/output to a connected server

$
0
0
Hello all.

I have a server that, on connection with a private key, runs a custom command (ie no shell, nor any pseudo-TTY allocation is required) that expects UTF-8 encoded text, multiple lines until a special end-of-packet line, then outputs UTF-8 encoded text, multiple lines until a special (same, actually) end-of-packet line, then waits for the next input "package".

I have managed to connect to the server (verified by the auth.log file), so assume I have a SshClient object which just ran successfully the Connect method.

How can I proceed to repeat the cycle of (send multiple lines, send special line, read multiple lines until special line is read) ?

Thanks in advance.

Patch Uploaded: #17494

$
0
0

Corillian has uploaded a patch.

Description:
Line 127 in PseudoTerminalInfo.cs incorrectly serializes this.Rows a second time instead of this.PixelWidth. I've uploaded a new file with the fix.

New Post: What are the list callbacks?

$
0
0
I'm trying to implement a function similar to the ListDirectory function for SftpClient, but that is capable of listing the contents of sub-directories as well. I noticed that the signature for ListDirectory is as follows:
public IEnumerable<SftpFile> ListDirectory(string path, Action<int> listCallback = null)
What exactly is the Action<int> listCallback parameter for? I did some research and came to something about delegates and callbacks being functions that are called after the main function finishes. But I'm still a bit lost as to what their use is here.

New Post: How to get response stream from server

$
0
0
Hello All,


I have server application running on linux and using SSH.Net as client.
Server application is listening on localhost and port 9001.
After providing credential I am able to connect server application can pass data as stream and server application is responding with data.

Server should send some data back that I am not able to capture. I am stuck in getting data back from server.



Channel channel = session.openChannel("direct-tcpip");
            //(channel).setInputStream(Console.OpenStandardInput());
            str ss = new str();
            ss.message_sequence_number = 4;
            ss.message_type = 0;

            var ba = StructureToByteArray(ss);
            Stream strm = new MemoryStream(ba);

            (channel).setInputStream(strm, true);


            (channel).setOutputStream(Console.OpenStandardOutput(), true);
            //(channel).setOutputStream(ms, true);

            ((ChannelDirectTCPIP) channel).setHost(host);
            ((ChannelDirectTCPIP) channel).setPort(port);

           channel.connect();
//doubt in this line
            FSM.DotNetSSH.java.io.InputStream fis = channel.getInputStream(); 


             while (!channel.isClosed())
            {
                var a = channel.getInputStream();
                Stream b = channel.getOutputStream();
                Thread.Sleep(500);
                FSM.DotNetSSH.jsch.Buffer bufff = new FSM.DotNetSSH.jsch.Buffer();
                session.read(bufff);
            }

Please provide technical help how to get back data, here I am casting structure object to stream array and sending, note: server application is written in C++ application.
sinha.vishal0@gmail.com

Created Unassigned: The output thread in Shell.Start() is not properly synchronized which causes a race condition [2675]

$
0
0
The output thread within Shell.Start() is not properly synchronized. Specifically the call to EventWaitHandle.WaitAny() is waiting until the asynchronous BeginRead() operation is finished which occurs at the moment EndRead() returns within the callback. At this point a new BeginRead() operation is queued, potentially before the data in buffer has had an opportunity to hit the socket, which causes a race condition. In the case where TUNING is not defined a Take() call is made to copy the contents of buffer. In this case there is still a race condition as another asynchronous BeginRead() operation may have already been initiated and could be overwriting the contents of buffer before the Take() begins.

The solution is to wait on a ManualResetEventSlim that doesn't get set until both the BeginRead() and _channel.SendData() operations are complete. I've attached a patched Shell.cs that fixes this issue and will formally submit the file as a patch as well.

Patch Uploaded: #17498

$
0
0

Corillian has uploaded a patch.

Description:
Issue 2675:

The output thread within Shell.Start() is not properly synchronized. Specifically the call to EventWaitHandle.WaitAny() is waiting until the asynchronous BeginRead() operation is finished which occurs at the moment EndRead() returns within the callback. At this point a new BeginRead() operation is queued, potentially before the data in buffer has had an opportunity to hit the socket, which causes a race condition. In the case where TUNING is not defined a Take() call is made to copy the contents of buffer. In this case there is still a race condition as another asynchronous BeginRead() operation may have already been initiated and could be overwriting the contents of buffer before the Take() begins.

The solution is to wait on a ManualResetEventSlim that doesn't get set until both the BeginRead() and _channel.SendData() operations are complete. I've attached a patched Shell.cs that fixes this issue and will formally submit the file as a patch as well.

Created Unassigned: Not possible to delete a Symbolic Link with SftpClient [2679]

$
0
0
I created a Symbolic Link with SftpClient.SymbolicLink but I found no method to delete it. SftpClient.Delete or SftpClient.DeleteDirectory does not work for Symbolic Links. A new method DeleteSymbolicLink needed.

Created Unassigned: SOCKS Proxy - Port is wrongly written to socket [2680]

$
0
0
Hi,

The port to write to socket should be masked and bit shift instead of dividing and modulus.

// Send port
//SocketWriteByte((byte)(ConnectionInfo.Port / 0xFF));
//SocketWriteByte((byte)(ConnectionInfo.Port % 0xFF));
// Mask & bit shift, not divide or modulus
SocketWriteByte((byte)((ConnectionInfo.Port & 0xFF00) >> 8));
SocketWriteByte((byte)(ConnectionInfo.Port & 0xFF));

Thanks.

Reviewed: 2014.4.6-beta2 (May 13, 2015)

$
0
0
Rated 5 Stars (out of 5) - Great stuff. Straightforward and easy to use.

New Post: SshOperationTimeoutException trying to start a service on remote server via C# app

$
0
0
Ok, so I may have some more insight to this issue (finally), if you have a moment to confirm or deny what I am seeing/assuming:

Most of my commands run a command and exit without spawning any child processes, but when attempting to start a daemon via init or running a script that loops infinitely, I seem to run into this timeout issue. The assumption is the child process is attached to the SSH session via stdin/stdout/stderr and since the process is a daemon, it won't be stopping on its own, thus we never end the session and the timeout occurs. Does that jive at all? If it does, is there a mechanism to avoid this? I have seen a few things online on how to redirect stdout/stderr away from the session for a long running script: http://serverfault.com/questions/36419/using-ssh-to-remotely-start-a-process, but those things will suppress the ability to get good return codes and command output.

Created Unassigned: [URGENT]Renci.SshNet for .Net Compact Framework 3.5 [2681]

$
0
0
Hi,

I remember seeing this somewhere and downloading a DLL for the same, but can find it now.
Is Renci.SSHNet supported for .Net Compact Framework 3.5? If Yes, can anyone provide pointers for the DLL download?

Thanks.

Created Unassigned: Not executing file manipulation commands using ssh.net library [2682]

$
0
0
My code uses ssh.net library to connect to windows server. It is working well when I access running exe, start and stop those exe but it gives me error "AllowDesktopAccess failed.
Unable to execute command or shell on remote system: Failed to Execute process" when I do file manipulations like cd, cd.., dir, copy

New Post: Not executing file manipulation commands using ssh.net library

$
0
0
My code uses ssh.net library to connect to windows server. It is working well when I access running exe, start and stop those exe but it gives me error "AllowDesktopAccess failed.
Unable to execute command or shell on remote system: Failed to Execute process" when I do file manipulations like cd, cd.., dir, copy.
Is it that ssh.net library does not support file manipulation?

New Post: ksh not found when executing command using the sshCommand.Execute

$
0
0
Hello,
I'll appreciate your help with the following issue.
i am trying to execute command using the following syntax :

SshCommand command = cSSH.CreateCommand("isql -Uun -Ppass -i/Directory1/Directory2/Directory3/Directory4/filename.sql -o/Directory1/Directory2/Directory3/Directory4/log/filename.log");

command.Execute();

when running it from shell the command success but when I run it using the ssh i get "ksh isql : not found"

anyone knows how can I overcome this issue?

thank you in advance!

New Post: Causes of "Server response does not contain SSH protocol identification"

$
0
0
Hello,

Does anyone ever ran into the "Server response does not contain SSH protocol identification" error?

What can cause that?


I'm using the library in a website to transfer file to another server using sftp. When testing the website from my workstation, everything works. But when I deploy on the dev server (or production) I get that error.

Firewall port is open (I was first getting a firewall error before the port was open)

Anyone got an idea about that error?

Thanks,
Philippe

New Post: changing users command

$
0
0
hello, I'll really appreciate some help in the following issue: i am trying to run some isql scripts using SSH. how can I change the user to be superuser? (comand: su -) ?

New Post: Documentation Empty

$
0
0
Hi,

i've downloaded the SshNet.Help.chm but when i open... no item have text. I see the documentation structure, but no text.

Any known issue ? I'm using windows 8.

New Post: Documentation Empty

$
0
0
forget it... i've missed the Unblock-file on powershell. Thanks ;)

New Post: Identifying that a command has finished (ShellStream)

$
0
0
21region wrote:
We have solved our local problem (as far as I understand, it is not a general solution) by adding into source code overloaded version of RunCommand(, Action<> InteractiveResponse). We have found that, when an interactive program asks for input (even if the prompt is empty) SshCommand's method Channel_DataReceived() gets fired. When this happens, we immediately ::SendData(...). These data are then pushed by sshd into remote program's stdin. It seems that these follow up messages do not violate any RFC.
Hi, any chance you can include a code sample?

New Post: Stability while in beta; "stable" timeframe

$
0
0
Any further progress on this?
Its tempting to create a fork on github as there would be much more involvement and community contributions. I have hit a bug in latest stable that has been fixed in beta2 so bit the bullet and considered referencing the beta in my project however am how consistently hit with the #2591 described above so am stuck between a rock and a hard place.
either a beta3 or new stable would be great right now as the codefix looks to already be in place .....
Viewing all 2955 articles
Browse latest View live


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