Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What format of private key does SSH remote debugging in Visual Studio take?

I have a .NET 5 application running on a Debian server that I would like to attach a debugger to. The debugger I am trying to use is the one integrated into Visual Studio 2019.

I meet all the prerequisites listed in the documentation.

When setting up a new connection, a password connection works. However, none of my attempts with a private key result in a usable connection.

This private key works well when connecting via both PuTTY and the Windows OpenSSH binary outside of Visual Studio. Therefore, the underlying SSH tooling appears to be set up correctly.


Attempts:

  • Unprotected OpenSSH-compatible private key:

    Results in a %LocalAppData%\devenv_exe_linux_connection_error_133651_090121.log containing just the text Bad Data.

    Also says Passphrase invalid on the empty passphrase box

  • Password-protected OpenSSH-compatible private key:

    Exactly the same result as the unprotected key. Bad Data. and Passphrase invalid.

  • Unprotected PuTTY-compatible private key:

    Host/port textboxes report Failed to negotiate host key algorithm. Only RSA and DSA host keys are supported. (server has ecdsa/ed25519/rsa host keys available, also the ecdsa host key was accepted by password auth)

    Private key file textbox reports An error occurred connecting using private key ...

    Empty passphrase textbox reports Passphrase invalid

  • Password-protected PuTTY-compatible private key:

    Exactly the same result as the unprotected key. Failed to negotiate host key algorithm. / An error occurred connecting using private key / Passphrase invalid.

At this point it's unclear what key format Visual Studio supports, as I have tried all the common ones.

Ideally I'd like to use the key I have stored in Pageant-compatible KeeAgent, also exposed via an OpenSSH-compatible socket. But I'll settle for getting a private key via file working.


Versions:

  • Visual Studio 2019 Professional, Version 16.11.2
  • dotnet SDK 5.0.101 on Debian Buster
like image 474
Bob Avatar asked Nov 06 '22 00:11

Bob


1 Answers

What worked for me connecting to a dot net core 2.1 process on Linux was this:

  • open puttygen, load the putty private key
  • specify a passphrase to export the key
  • In the Conversions menu, choose Export OpenSSH key

Then, in Visual Studio 2019:

  • go to Tools / Options / Cross platform / connection manager
  • add a new connection
  • set the hostname, port and username.
  • for Auth type, select private key and then select the file exported above as the private key. Set the passphrase you used before.
  • Click the Connect button, it should print something like "connection verified"
  • Close options

Then in the attach to process dialog, Connection type = SSH and select the Connection target you just configured, it should be able to show the remote processes and let you attach.

like image 119
David Suarez Avatar answered Dec 31 '22 10:12

David Suarez