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

New Post: SFTP connection problem - Timeout

$
0
0
I am having a problem with a simple sftp file transfer. I am starting to wonder if there is a problem when I change the port from standard 22 to a custom port of 5929. I can connect to the remote server using putty and Winscp using port 5929. My application will connect to my local Linux machine (CENTOS) using port 22 without a problem. However, when I try to use the application to connect to the remote server on port 5929 it times out and the log does not show that there was an attempt.

Any ideas?

Note: This is a test program, the idea is to use a configuration file for the data.

const int port = 5929;
        const string host = "****";
        const string userName = "******";
        const string password = "***";
        const string workingdirectory = "/";
        const string uploadfile = @"c:/Projects/test/HCCS.txt";


        var keyboardAuthMethod = new KeyboardInteractiveAuthenticationMethod(userName);

        keyboardAuthMethod.AuthenticationPrompt += delegate(Object senderObject, AuthenticationPromptEventArgs eventArgs)
        {
            foreach (var prompt in eventArgs.Prompts)
            {

                if (prompt.Request.Equals("Password: ", StringComparison.InvariantCultureIgnoreCase))
                {
                    prompt.Response = password;

                }

            }

        };

        var passwordAuthMethod = new PasswordAuthenticationMethod(userName, password);

        var connectInfo = new ConnectionInfo(host, userName, passwordAuthMethod, keyboardAuthMethod);


        Console.WriteLine("Creating client and connecting");
        Console.WriteLine(host);

        using (SftpClient client = new SftpClient(connectInfo))
        {
            try
            {
                client.OperationTimeout = new TimeSpan(0, 0, 30);
                client.Connect();
            }
            catch (Exception exe)
            {
                Console.WriteLine(exe.ToString());
            }
            if (client.IsConnected)
            {
                Console.WriteLine("Connected to {0}", host);
                var ls = client.ListDirectory(".");
                foreach (var s in ls)
                {
                    Console.WriteLine(s);
                }
            }
            else
                Console.Write("Not Connected");


            Console.Read();

New Post: Control M charecters

New Post: SFTP connection problem - Timeout

$
0
0
You don't use your "const int port = 5929;" anywhere.

New Post: SFTP connection problem - Timeout

$
0
0
Aha...I had been messing with so much trying to get the authentication all figured out which was interesting but fun... the examples that I had been using all worked on port 22 I added the port cont into the connectInfo and it worked first time

da_rinkes -thanks for the extra set of eyes...appreciate it ..
dave

New Post: Problem to connect using the PROXY Squid

$
0
0
I tested with other libraries SFTP: chilkatsoft and nSoftware.
I have no problem using the SQUID proxy with the same settings I have indicated ..

New Post: Problem to connect using the PROXY Squid

$
0
0
no shirt, no code, no service ;)

Please give us your code. Everything else is just guessing.

New Post: Unable to CD when connecting through SSH

$
0
0
I am connecting to a windows computer to an ubuntu comupter using SSH and have established connection. However, I'm unable to perform commands like cd.

I am able to perform ls and ip addr ls.

I have copied the private key file generated from the ubuntu onto windows and placed it in the code as shown below.
var keyFile = new PrivateKeyFile(File.OpenRead(@"filepath"));
            
            try
            {
                //connect here
                var con = new ConnectionInfo(addr, user, new PasswordAuthenticationMethod(user, passwd), new PrivateKeyAuthenticationMethod(user, keyFile));

                //client = new SshClient(addr, user, passwd);
                client = new SshClient(con);
                client.Connect();
}

New Post: Sending Escape+Shift+F6

$
0
0
Hi All,

Are there possible solutions on sending the above 3 keys via shellstream? I have been looking around but i can't seem to find any clue.

New Post: Urgent: ScpClient - How to download entire remote directory to local directory

$
0
0
Hello All,

I am trying to download all files and sub-folder from a remote directory to local directory. For this I am using "ScpClient" and method name is "Download". Based on documentation (if I have not read it wrongly) it says "Downloads the specified directory from the remote host to local directory." But the same is not happening for me.

Below is the code, please let me know if I am doing any mistake. Any pointers/help are greatly appreciated (its urgent for a go-live project).
            public void TestSynchronisation(string hostaddress, string username, string password, string hostfolderpath, string destinationPath)
        {
            using (var sftp = new ScpClient(hostaddress, username, password))
            {
                sftp.Connect();

                DirectoryInfo dirInfo = new DirectoryInfo(destinationPath);
                sftp.Downloading += sftp_Downloading;
                sftp.ErrorOccurred += sftp_ErrorOccurred;
                sftp.Download(hostfolderpath, dirInfo);            }
        }

        void sftp_ErrorOccurred(object sender, Renci.SshNet.Common.ExceptionEventArgs e)
        {
            Console.Write(e.Exception.Message.ToString());
            Console.ReadLine();
        }

        void sftp_Downloading(object sender, Renci.SshNet.Common.ScpDownloadEventArgs e)
        {
            Console.WriteLine(e.Filename.ToString());
            Console.WriteLine(e.Downloaded.ToString());
        }    
PS: It does not throw any error either shows any progress via downloading event.

Regards,
Chirag

New Post: Executing Powershell command through freeSSHd is blocking SSH.NET

$
0
0
The SSH.NET library is locking up when I run a Powershell script through freeSSHd. Executing VBScripts through cscript works without issue. I have included example C# code for both (see below). In both cases, the scripts simply involves writing a string to STDOUT.

Stepping into the code, the code is blocking on Session.SocketRead after the SSH_MSG_CHANNEL_DATA message occurs. More specifically, executing the VBScript command generates a SSH_MSG_CHANNEL_REQUEST message, but executing the Powershell command does not.

I have tested the command line in a Command Prompt as well as executing it through an SSH client (putty) without issue. Can anyone give me a workaround or confirm whether this is a bug in the SSH.NET or freeSSHd?

// This works without issue
var client = new Renci.SshNet.SshClient("127.0.0.1", "username", "password");
client.Connect();
var command = client.CreateCommand("cscript.exe /nologo C:\test.vbs");
command.Execute();

// This blocks
var client = new Renci.SshNet.SshClient("127.0.0.1", "username", "password");
client.Connect();
var command = client.CreateCommand("PowerShell.exe C:\test.ps1");
command.Execute();

New Post: sshnet forward port dynamic problem

$
0
0
Hello,

I using GeckoWebBrowser and i want to fake my ip location, this is my code
                Skybound.Gecko.GeckoPreferences.User["network.proxy.type"] = 1; 
                Skybound.Gecko.GeckoPreferences.User["network.proxy.share_proxy_settings"] = true;
                Skybound.Gecko.GeckoPreferences.User["network.proxy.socks"] = "127.0.0.1";
                Skybound.Gecko.GeckoPreferences.User["network.proxy.socks_port"] = 1080;
                Skybound.Gecko.GeckoPreferences.User["network.proxy.socks_remote_dns"] = true;
                Skybound.Gecko.GeckoPreferences.User["network.proxy.socks_version"] = 5; 
                Skybound.Gecko.GeckoPreferences.User["network.proxy.no_proxies_on"] = "localhost, 127.0.0.1";
My geckowebbrowser work well when i use Bitvise SSH Client to forward port dynamic (create sock5 127.0.0.1:1080)

But my geckowebbrowser error (connection timeout) when i use sshnet (i not use bitvise ssh client) to forward port dynamic, this is my code
                SshClient client = new SshClient(host, username, password);
                client.KeepAliveInterval = new TimeSpan(0, 0, 30);
                client.Connect();
                ForwardedPortDynamic port = new Renci.SshNet.ForwardedPortDynamic"127.0.0.1", 1080);
                client.AddForwardedPort(port);
                client.SendKeepAlive();
                port.Start();
                if (port.IsStarted)
                    this.geckoWebBrowser.Navigate("http://google.com");
                else
                    MessageBox.Show("Error");
Please tell me what did i wrong this code and how i fix it.

Thank you!

Created Unassigned: ForwardedPortLocal hang connection to mysql on large query [1775]

$
0
0
Hi,

I create a ForwardedPortLocal on start of application and stops it on exit and it works fine. The application ask mysql about 20 diffrent querys and 19 of them works. The one that hangs the application is a massive data store query that stores thousens of row to the db. I build up the query like this:
INSERT MyTable (col1,col2,col3) VALUES
(Value1,value2,value3),
(Value1,value2,value3),
(Value1,value2,value3),
(Value1,value2,value3),
(Value1,value2,value3)
......

If i build up the query like this with 1000 values it will just hang. If i reduse it to just 300 it works fine.
It works greate if I skipp the ssh.net part in the application and create a tunnel outside the application with a some other ssh application.

I can reproduce this error every time, does not work with 1000,900,800,700,600,500 or 400 but with 300 it workes every time.


I tested to run the upload in a thread and added a button to check the ssh client and the ForwardedPortLocal and both of them is activ if i ask them when it is hanged.

New Post: ForwardedPortLocal hang connection to mysql on large query

$
0
0
Hi,I create a ForwardedPortLocal on start of application and stops it on exit and it works fine. The application ask mysql about 20 diffrent querys and 19 of them works. The one that hangs the application is a massive data store query that stores thousens of row to the db. I build up the query like this:INSERT MyTable (col1,col2,col3) VALUES 
(Value1,value2,value3),
(Value1,value2,value3),
(Value1,value2,value3),
(Value1,value2,value3),
(Value1,value2,value3)
......

If i build up the query like this with 1000 values it will just hang. If i reduse it to just 300 it works fine.

It works greate if I skipp the ssh.net part in the application and create a tunnel outside the application with a some other ssh application.

I can reproduce this error every time, does not work with 1000,900,800,700,600,500 or 400 but with 300 it workes every time.I tested to run the upload in a thread and added a button to check the ssh client and the ForwardedPortLocal and both of them is activ if i ask them when it is hanged.

Someone else that got this problem ans solved it?

New Post: Problem to connect using the PROXY Squid

$
0
0
using System;
using Renci.SshNet;

namespace ConsoleApplication1
{
class Program
{
    static void Main(string[] args)
    {

        const string host = "demo.wftpserver.com";
        const int port = 2222;
        const string userName = "demo-user";
        const string password = "demo-user";

        const ProxyTypes pType = ProxyTypes.Http;
        const string pHost = "127.0.0.1";
        const int pPort = 3128;

        var sFtp_Autentication = new PasswordAuthenticationMethod(userName, password);

        var connectInfo = new ConnectionInfo(host, port, userName, pType, pHost, pPort, "", "", sFtp_Autentication);

        //var connectInfo = new ConnectionInfo(host, port,userName,  sFtp_Autentication);

        Console.WriteLine("Creating client and connecting");
        Console.WriteLine(host);

        using (SftpClient client = new SftpClient(connectInfo))
        {
            try
            {
                client.OperationTimeout = new TimeSpan(0, 0, 30);
                client.Connect();
            }
            catch (Exception exe)
            {
                Console.WriteLine(exe.ToString());
            }
            if (client.IsConnected)
            {
                Console.WriteLine("Connected to {0}", host);
                var ls = client.ListDirectory(".");
                foreach (var s in ls)
                {
                    Console.WriteLine(s);
                }
            }
            else
                Console.Write("Not Connected");


            Console.Read();
        }

    }
}

}

_Connect ok using:

var connectInfo = new ConnectionInfo(host, port,userName, sFtp_Autentication);

Creating client and connecting
demo.wftpserver.com
Connected to demo.wftpserver.com
Name You can upload file into [upload], Length 34, User ID 0, Group ID 0, Access
ed 19/09/2013 9:27:44, Modified 08/08/2013 9:23:27
Name download, Length 4096, User ID 0, Group ID 0, Accessed 22/09/2013 4:56:11,
Modified 07/08/2013 18:05:06
Name upload, Length 20480, User ID 0, Group ID 0, Accessed 23/09/2013 3:08:00, M
odified 23/09/2013 7:22:03

_Not Connect using:
 var connectInfo = new ConnectionInfo(host, port, userName, pType, pHost, pPort, "", "", sFtp_Autentication);
_Mensage with Proxy port 2222 worked and allowed (not OK):

Creating client and connecting
demo.wftpserver.com
Renci.SshNet.Common.SshOperationTimeoutException: Socket read operation has time
d out
en Renci.SshNet.Session.SocketReadLine(String& response)
en Renci.SshNet.Session.ConnectHttp()
en Renci.SshNet.Session.Connect()
en Renci.SshNet.BaseClient.Connect()
en ConsoleApplication1.Program.Main(String[] args) en c:\users\manuel\documen
ts\visual studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Program.c
s:línea 34
Not Connected


_Message if the proxy is stopped (is OK):

Creating client and connecting
demo.wftpserver.com
System.Net.Sockets.SocketException (0x80004005): No se puede establecer una cone
xión ya que el equipo de destino denegó expresamente dicha conexión 127.0.0.1:31
28
en System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
en Renci.SshNet.Session.SocketConnect(String host, Int32 port)
en Renci.SshNet.Session.Connect()
en Renci.SshNet.BaseClient.Connect()
en ConsoleApplication1.Program.Main(String[] args) en c:\users\manuel\documen
ts\visual studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Program.c
s:línea 34
Not Connected


_Thanks for your help.

New Post: Problem to connect using the PROXY Squid

$
0
0
Please use some formatting. Getting a headache trying to encrypt this...

New Post: Problem to connect using the PROXY Squid

$
0
0
As I proceeded to format the message above.
Sorry, and Thanks.

New Post: An established connection was aborted by the software in your host machine.

$
0
0
Is there a reason for these values to be hardcoded to 1024 bit?

(in KeyExchangeDiffieHellmanGroupExchangeSha1.cs and KeyExchangeDiffieHellmanGroupExchangeSha256.cs)
           MinimumGroupSize = 1024,
            PreferredGroupSize = 1024,
            MaximumGroupSize = 1024,
I guess this is why the connection fails here...

New Post: An established connection was aborted by the software in your host machine.

$
0
0
Yes, when I change these values to (1024, 2048, 8192) it works.

But it would be better if these could be set by a property...

New Post: Urgent: ScpClient - How to download entire remote directory to local directory

$
0
0
I request to the board users/senior members reply (if it is a known issue).

Created Unassigned: DH Key Exchange is limited to 1024 bit [1777]

$
0
0
DH Key Exchange is limited to 1024 bit

Connections to a server with a higher DH Group Exchange bit-length failing with "An established connection was aborted by the software in your host machine.".

[SSH] 2013/09/05 14:22:55,882
Received Message 34 on connection (PID 500):
--> Message is GEX_REQUEST:
---> client requested group data bit length: min 1024, max 1024, preferred 1024
----> did not find any matching group, giving up
--> error handling record, closing connection & bailing out


Bit-length should be increased in KeyExchangeDiffieHellmanGroupExchangeSha1.cs and KeyExchangeDiffieHellmanGroupExchangeSha256.cs to MinimumGroupSize = 1024, PreferredGroupSize = 2048 and MaximumGroupSize = 8192.

And it should be possible to change these with a property.
Viewing all 2955 articles
Browse latest View live


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