question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't connect (SCP, SSH) in Xamarin Android

See original GitHub issue

Calling Connect() with an SSH or SCP client (and likely others) causes this exception. Does this library not work in Xamarin Android?

I don’t see where in this library ti’s throwing NotImplementedException, so I’m guessing something missing in Mono / .NET Standard?

2021-04-15 12:29:05.030 16384-16427/? E/MySessionStarter: Failed uploading file: System.NotImplementedException: The method or operation is not implemented.
      at Renci.SshNet.Session.WaitOnHandle (System.Threading.WaitHandle waitHandle, System.TimeSpan timeout) [0x00041] in <c7169cd606324a41b931acc40c516428>:0 
      at Renci.SshNet.Session.WaitOnHandle (System.Threading.WaitHandle waitHandle) [0x0000d] in <c7169cd606324a41b931acc40c516428>:0 
      at Renci.SshNet.Session.Connect () [0x0017b] in <c7169cd606324a41b931acc40c516428>:0 
      at Renci.SshNet.BaseClient.CreateAndConnectSession () [0x00053] in <c7169cd606324a41b931acc40c516428>:0 
      at Renci.SshNet.BaseClient.Connect () [0x0001f] in <c7169cd606324a41b931acc40c516428>:0 
    ....
    ```

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:13

github_iconTop GitHub Comments

1reaction
ts678commented, May 22, 2021

A workaround is try new ECDsaCng() to see if it’s implemented. If exception occurs, go through HostKeyAlgorithms.Keys, and HostKeyAlgorithms.Remove(key) the ones beginning with ecdsa (inspired by Limit what algorithms or ciphers are used #730).

1reaction
ts678commented, May 12, 2021

It’s related to Session.WaitOnHandle being not implemented.

It seems Session.WaitOnHandle is in https://github.com/sshnet/SSH.NET/blob/develop/src/Renci.SshNet/Session.cs You can see comments there about the receive thread. I’m not an SSH.NET developer. It’d be nice if they can help.

It might be waiting at the below for the receive thread to either receive, or find an exception, and it got exception:

https://github.com/sshnet/SSH.NET/blob/f072c5f1a1bb607797a85cd43cf498ec541af3ab/src/Renci.SshNet/Session.cs#L852-L852

I think my issue is happening way before a connection

The stack trace names suggest that it’s working on connect, but it likely died before SSH connection was finished. The behavior we see with certain SFTP servers such as Bitvise (but not OpenSSH, at least so far) is a failure after a

Server: Elliptic Curve Diffie-Hellman Key Exchange Reply, New Keys Message Code: Elliptic Curve Diffie-Hellman Key Exchange Reply (31) is received, containing KEX host key (type: ecdsa-sha2-nistp384) I think the received protocol is RFC 5656 ECDH Key Exchange here.

Processing of that server SSH_MSG_KEX_ECDH_REPLY might be here:

https://github.com/sshnet/SSH.NET/blob/f072c5f1a1bb607797a85cd43cf498ec541af3ab/src/Renci.SshNet/Session.cs#L1298-L1302

and at some point the key from the server might hit here:

https://github.com/sshnet/SSH.NET/blob/a5bd08d655bb6a3c762306472cec354556dca3a3/src/Renci.SshNet/Security/Cryptography/EcdsaKey.cs#L238-L242

ECDsa Class and ECDsaCng Class get involved, and so maybe it hits the NotImplementedException around here.

NotImplementedException has been in ECDsaCng.cs a long time, maybe added here, then later exposed through Support newer SSH Ciphers and MACs #53. If you’re still on the 2016 release, ignore all this. It applies to 2020’s.

Any SSH.NET developer comments? Could these very welcome new capabilities be exposing an old gap in mono? Please forgive any mistakes in the details. I don’t have a debugger, or know the protocol or the code all that well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Xamarin Pair to Mac error installing Broker - ScpClient lost ...
The Visual Studio log shows an error that the SSH.NET ScpClient used by Xamarin is losing connection transferring Broker.zip from the VS ...
Read more >
Can't connect (SCP, SSH) in Xamarin Android
Can't connect (SCP, SSH) in Xamarin Android.
Read more >
A problem occurred while using the SCP Client. Trying ...
Trying again with a new SCP connection... 3>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Xamarin\Xamarin.Apple.
Read more >
SSH and SCP/SFTP library for Xamarin Android
I posted a question here, but I'm reaching on to this sub about looking for a .NET library for SSH and SCP/SFTP that...
Read more >
Using scp to transfer files to an android device - ssh
I can not seem to 'touch' the file (which is on the remote server) from the android device: No such file or directory....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found