sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
http://sshnet.github.io/SSH.NET/
MIT License
4.03k stars 935 forks source link

"Session operation has timed out" on Azure Function #151

Open maikgroenewegen opened 7 years ago

maikgroenewegen commented 7 years ago

I'm try to connect to a SFTP server from an Azure Function and I keep getting a "Session operation has timed out". I'm on version "2016.0.0". I've build a similar function using WinSCP and that works fine and the same applies to running the CLI command SFTP from the Kudu prompt.

I'm using the following code:

public static void Run(TimerInfo myTimer, TraceWriter log) { string sftp_host = ; string sftp_user = ; string sftp_privateKey = @ var stream = new FileStream(sftp_privateKey, FileMode.Open, FileAccess.Read); var privateKeyFile = new PrivateKeyFile(stream); AuthenticationMethod authenticationMethod = new PrivateKeyAuthenticationMethod(, privateKeyFile); ConnectionInfo ConnNfo = new ConnectionInfo(sftp_host, sftp_user, authenticationMethod); SftpClient client = new SftpClient(ConnNfo); try { client.Connect();

        }
        catch (Exception ex)
            {
                log.Info("Error Message: " + ex.Message);
                client.Disconnect();
            }

}

maikgroenewegen commented 7 years ago

Also tried it in a PowerShell version (same error) and with the latest beta.

drieseng commented 7 years ago

I have access to Azure, but I have to admit that I never used it. I'm afraid it'll take me ages to reproduce this issue. This may be a duplicate of issue #130, but without more info it's hard to tell.

maikgroenewegen commented 7 years ago

I've you could let me know how to activate logging/debugging I might be able to get more detailed info.

maikgroenewegen commented 7 years ago

You're right it is related to issue #130.I implemented the fix as mentioned in the other issue and my PowerShell version now works.

maikgroenewegen commented 7 years ago

I changed line 109 in KeyExchangeDiffieHellman.cs to a fixed single number.