dotnet / dotnet/vscode-csharp

.NET Core remote debug via SSH isn't working as advertised

Open
#3,482 10 comments 0 reactions 0 assignees View on GitHub
Debugger Needs Investigation OmniSharp Triaged
Dominant language
TypeScript
Stars
3.1k
Forks
737
Avg merge
17h 56m
Merged PRs (30d)
21

Description

https://github.com/microsoft/vscode-remote-release/issues/2074#issuecomment-568572887

from @adaviding

## Issue Description ##
I am following the ssh debug scenario in [your documentation](https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes).

I cannot remote debug using the SSH technique (hereafter known as "method 1").

Possibly related to https://github.com/OmniSharp/omnisharp-vscode/issues/3347.

## Steps to Reproduce ##
I am following the ssh debug scenario in [your documentation](https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes).

I am having a problem with method 1 (remote debugging via ssh).

I have gotten this working with method 2 (remote debugging via docker exec), so you know most of the pieces setup correctly.

Here is the launch.json content which shows how both methods are configured within my instance of VSCode. (Both methods are configured similarly with some minor differences, as shown in your documentation.)

```
{
// Method 1 -- Not working
// This is not currently working. We are supposed to be able to connect to a remote debugger using this config via ssh
// This is taken from https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-ssh-attach-with-launchjson
"name": ".NET Core SSH Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickRemoteProcess}",
"pipeTransport": {
"pipeProgram": "ssh",
"pipeArgs": [ "-T", "-i", "C:/Users/ding/.ssh/id_rsa", "-o", "StrictHostKeyChecking=no", "root@localhost", "-p", "10022"],
//"pipeArgs": [ "-T", "root@localhost", "-p", "10022"],
"debuggerPath": "/var/vsdbg/vsdbg",
"pipeCwd": "${workspaceRoot}",
"quoteArgs": true
},
"sourceFileMap": {
"/home/ExampleAccount/ExampleProject": "${workspaceRoot}"
}
},
{
// Method 2 -- Working
// This is how we remote debug an application running in a docker container.
// This is taken from https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#configuring-docker-attach-with-launchjson
"name": ".NET Core Docker Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickRemoteProcess}",
"pipeTransport": {
"pipeProgram": "docker",
"pipeArgs": [ "exec", "-i", "docker-images_debug_test_1" ],
"debuggerPath": "/var/vsdbg/vsdbg",
"pipeCwd": "${workspaceRoot}",
"quoteArgs": false
},
"sourceFileMap": {
"/home/ExampleAccount/ExampleProject": "${workspaceRoot}"
}
}
```

I have also setup and configured openssh-server (running within the docker container) to the point that you can ssh into the container from the host machine by executing a simple command using either Command Prompt or GitBash on the host machine:

```bash
ssh -i C:/Users/ding/.ssh/id_rsa -o StrictHostKeyChecking=no root@127.0.0.1 -p 10022
```

## Expected Behavior ##
Debugger can attach via SSH.

## Actual Behavior ##
When I try to connect a remote debugger using method 1 (via ssh), it doesn't actually connect; it just hangs.

## Logs ##

### remote-attach log ###
In the OUTPUT tab (with "remote-attach" selected) I can see a message:

```
Executing: ssh -T -i C:/Users/ding/.ssh/id_rsa -o StrictHostKeyChecking=no root@localhost -p 10022 "sh -s" < C:\Users\ding\.vscode\extensions\ms-vscode.csharp-1.21.9\scripts\remoteProcessPickerScript
```

At this point I should see some kind of UI which allows me to pick the PID but it doesn't appear. When I forcibly stop the docker container I immediately see additional text within the OUTPUT tab:

```
stderr: Connection to localhost closed by remote host.
Error Message: Command failed: ssh -T -i C:/Users/ding/.ssh/id_rsa -o StrictHostKeyChecking=no root@localhost -p 10022 "sh -s" < C:\Users\ding\.vscode\extensions\ms-vscode.csharp-1.21.9\scripts\remoteProcessPickerScript
Connection to localhost closed by remote host.
```

## Environment information ##

**VSCode version**: 1.41.1
**C# Extension**: 1.21.9

Dotnet Information
.NET Core SDK (reflecting any global.json):
Version: 3.1.100
Commit: cd82f021f4

Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.100\

Host (useful for support):
Version: 3.1.0
Commit: 65f04fb6db

.NET Core SDKs installed:
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.400 [C:\Program Files\dotnet\sdk]
2.1.401 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.504 [C:\Program Files\dotnet\sdk]
2.2.107 [C:\Program Files\dotnet\sdk]
2.2.109 [C:\Program Files\dotnet\sdk]
3.1.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.3-servicing-26724-03 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

Visual Studio Code Extensions

|Extension|Author|Version|
|---|---|---|
|cpptools|ms-vscode|0.26.2|
|csharp|ms-vscode|1.21.9|
|remote-wsl|ms-vscode-remote|0.41.6|;

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.