You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/python/debugging-python-code-on-remote-linux-machines.md
+17-21Lines changed: 17 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Debugging Python code on remote Linux computers
3
3
description: How to use Visual Studio to debug Python code running on remote Linux computers, including necessary configuration steps, security, and troubleshooting.
4
-
ms.date: 09/03/2018
4
+
ms.date: 10/15/2018
5
5
ms.prod: visual-studio-dev15
6
6
ms.technology: vs-python
7
7
ms.topic: conceptual
@@ -69,11 +69,9 @@ For details on creating a firewall rule for an Azure VM, see [Open ports to a VM
69
69
70
70
```python
71
71
import ptvsd
72
-
ptvsd.enable_attach('my_secret')
72
+
ptvsd.enable_attach()
73
73
```
74
74
75
-
The first argument passed to `enable_attach` (called "secret") restricts access to the running script, and you enter this secret when attaching the remote debugger. (Though not recommended, you can allow anyone to connect, use `enable_attach(secret=None)`.)
76
-
77
75
1. Save the fileand run `python3 guessing-game.py`. The call to `enable_attach` runs in the background and waits for incoming connections as you otherwise interact with the program. If desired, the `wait_for_attach` function can be called after `enable_attach` to block the program until the debugger attaches.
78
76
79
77
> [!Tip]
@@ -91,10 +89,7 @@ In these steps, we set a simple breakpoint to stop the remote process.
91
89
92
90
1. In the **Attach to Process** dialog that appears, set**Connection Type** to **Python remote (ptvsd)**. (On older versions of Visual Studio these commands are named **Transport**and**Python remote debugging**.)
93
91
94
-
1. In the **Connection Target** field (**Qualifier** on older versions), enter `tcp://<secret>@<ip_address>:5678` where `<secret>`is the string passed `enable_attach`in the Python code, `<ip_address>`is that of the remote computer (which can be either an explicit address or a name like myvm.cloudapp.net), and`:5678`is the remote debugging port number.
95
-
96
-
> [!Warning]
97
-
> If you're making a connection over the public internet, you should be using `tcps` instead and following the instruction below to [Secure the debugger connection with SSL](#secure-the-debugger-connection-with-ssl).
92
+
1. In the **Connection Target** field (**Qualifier** on older versions), enter `tcp://<ip_address>:5678` where `<ip_address>`is that of the remote computer (which can be either an explicit address or a name like myvm.cloudapp.net), and`:5678`is the remote debugging port number.
98
93
99
94
1. Press **Enter** to populate the list of available ptvsd processes on that computer:
100
95
@@ -116,7 +111,7 @@ In these steps, we set a simple breakpoint to stop the remote process.
116
111
1. Check that the secret in the **Connection Target** (or**Qualifier**) exactly matches the secret in the remote code.
117
112
1. Check that the IP address in the **Connection Target** (or**Qualifier**) matches that of the remote computer.
118
113
1. Check that you're opened the remote debugging port on the remote computer, and that you've included the port suffix in the connection target, such as`:5678`.
119
-
- If you need to use a different port, you can specify it in the `enable_attach` call using the `address` argument, asin`ptvsd.enable_attach(secret='my_secret', address= ('0.0.0.0', 8080))`. In this case, open that specific port in the firewall.
114
+
- If you need to use a different port, you can specify it in the `enable_attach` call using the `address` argument, asin`ptvsd.enable_attach(address= ('0.0.0.0', 8080))`. In this case, open that specific port in the firewall.
120
115
1. Check that the version of ptvsd installed on the remote computer as returned by `pip3 list` matches that used by the version of the Python tools you're using in Visual Studio in the table below. If necessary, update ptvsd on the remote computer.
121
116
122
117
| Visual Studio version | Python tools/ptvsd version |
@@ -131,9 +126,15 @@ In these steps, we set a simple breakpoint to stop the remote process.
131
126
|2013|2.2.2 |
132
127
|2012, 2010|2.1|
133
128
134
-
## Secure the debugger connection with SSL
129
+
## Using ptvsd 3.x
130
+
131
+
The following information applies only to remote debugging with ptvsd 3.x, which contains certain features that were removed in ptvsd 4.x.
132
+
133
+
1. With ptvsd 3.x, the `enable_attach` function required that you pass a "secret"as the first argument that restricts access to the running script. You enter this secret when attaching the remote debugger. Though not recommended, you can allow anyone to connect, use `enable_attach(secret=None)`.
135
134
136
-
By default, the connection to the ptvsd remote debug server is secured only by the secret andall data is passed in plain text. For a more secure connection, ptvsd supports SSL, which you set up as follows:
135
+
1. The connection target URLis`tcp://<secret>@<ip_address>:5678` where `<secret>`is the string passed `enable_attach`in the Python code.
136
+
137
+
By default, the connection to the ptvsd 3.x remote debug server is secured only by the secret andall data is passed in plain text. For a more secure connection, ptvsd 3.x supports SSL using the `tcsp` protocol, which you set up as follows:
137
138
138
139
1. On the remote computer, generate separate self-signed certificate and key files using openssl:
139
140
@@ -166,17 +167,12 @@ By default, the connection to the ptvsd remote debug server is secured only by t
166
167
167
168

168
169
169
-
### Warnings
170
-
171
-
Visual Studio prompts you about potential certificate issues when connecting over SSLas described below. You may ignore the warnings and proceed, but although the channel is still encrypted against eavesdropping it can be open to man-in-the-middle attacks.
172
-
173
-
1. If you see the **remote certificate isnot trusted** warning below, it means you did not properly add the certificate to the Trusted Root CA. Check those steps andtry again.
170
+
1. Visual Studio prompts you about potential certificate issues when connecting over SSL. You may ignore the warnings and proceed, but although the channel is still encrypted against eavesdropping it can be open to man-in-the-middle attacks.
1. If you see the **remote certificate isnottrusted** warning below, it means you did not properly add the certificate to the Trusted Root CA. Check those steps andtry again.
176
173
177
-
1. If you see the **remote certificate name does not match hostname**warning below, it means you did not use the proper hostname orIP address as the **Common Name** when creating the certificate.
1. If you see the **remote certificate name does not match hostname** warning below, it means you did not use the proper hostname orIP address as the **Common Name** when creating the certificate.
180
177
181
-
> [!Warning]
182
-
> At present, Visual Studio 2017 hangs when you ignore these warnings. Be sure to correct all problems before attempting to connect.
0 commit comments