Ptvs: Add remote debugging over SSH

Created on 19 Aug 2015  路  22Comments  路  Source: microsoft/PTVS

There doesn't seem to be a way to use ptvsd to do remote debugging over an SSH connection, which is unfortunate due to the kind of work I am doing, as I am running tasks on a linux supercomputer over SSH. Are you currently working on adding this feature?

Debugger enhancement

Most helpful comment

I like ptvs more than pyCharm for some reasons :) but...
It's a shame ptvs do not implement "remote debugging over an SSH connection" like pyCharm. I work a lot with boards like "Raspberry Pi" and I do not like to install a remote debugger server tool, and edit my modules with some special code, for such a task.

All 22 comments

I don't think we've had this request before, so it hasn't been on our plan.

I wonder whether you could achieve this by setting plink.exe (from PuTTY) as your interpreter path and some cleverly crafted SSH commands? @int19h will have a better idea.

Yes, this should be doable with SSH tunneling, following this guide as an example:

http://howto.ccs.neu.edu/howto/windows/ssh-port-tunneling-with-putty/

So you'd tunnel local port 5678 to the same remote port, and then use localhost as the qualifier in Attach to Process dialog.

Ok, thanks for the help. I was told that this was possible in PyCharm, but never followed up on this claim, but I like VS a lot more, so I was just asking.

I'm not sure whether this is due to my incompetence or to PTVS, but when I try to do the steps on the webpage and connect to localhost:5678 in Visual Studio, I get an error dialog box that says: Error displaying the Port Selector dialog for this transport. Not implemented

Are you clicking on the "Find" button, by chance? You need to enter the address in the Qualifier textbox and then press Enter to get the process list below to refresh.

Yes. I enter 'localhost:5678' into the Qualifier textbook, then press Find, and then get the error dialog box.

It's not the most well designed dialog, unfortunately.

The "Find" button is to help you find something to put in the Qualifier textbox, and we don't have any way to help you find anything.

Once you've typed something manually, hit Enter and it will refresh the list below.

Is perhaps my installation corrupted? I get the same error message (Error displaying the Port Selector dialog for this transport. Not implemented) when I click the Find box when it is empty...

No, we just don't implement the port selector dialog. The error message is 100% accurate.

You'll need to enter the host and port manually, then hit enter. Don't click the Find button.

It's still not working. I'm getting alternate error messages telling me that either that either the remote client is not supported by VS, that it can't connect to localhost:5678, or that it cannot find any running processes ( I followed the directions regarding importing ptvsd and the line ptvsd.enable_attach())....

Is one of those error messages "Remote server is not a supported Python Tools for Visual Studio debugging server"?

If so, then whatever you're doing when that particular one occurs, that should be the right sequence of steps. It means that it was actually able to reach out to the other side and initiate the handshake, but the protocol version was mismatched. So the tunnel is working in that case, you've just got something wrong on the other side.

Which version of PTVS are you running, and how did you install ptvsd on the remote machine?

For the remote machine - pip install ptvsd. Installed it in Python 3, which is what I am using to run the python program.
I am running PTVS 2.2 - the latest one, I believe.

I am running the Python jobs from a batch script is this maybe the problem?

How they're launched shouldn't matter, so long as they're still there when you are trying to attach (i.e. either a single job is sufficiently long running, or else it calls ptvsd.wait_for_attach() to pause execution until debugger is there).

That's weird. Is there any we can figure out what is causing the problem?

I'm going to try and set it up myself and see if I run into any issues. If I can't reproduce it, I'll ask you for more details about your setup.

Hm, the tunneling definitely works for me. Can you take a look at these screenshots and see if your setup is somehow different?

image

image

image

(Note that the forwarding is set to localhost, because the target host name is relative to the machine you're ssh'ing into - so if you want to forward to that very machine, localhost is the easiest way to specify that.)

Hmm, I think that I may have set the wrong port. I'll take a look when I get home

Still not working for me. Something I forgot to mention is that I am using a VPN as well as putty. Is this perhaps what is causing the issue?

So long as you can use Putty to actually connect to that machine, and it works (i.e. you have the shell), I'd expect the tunnel to work also. But I'm not really too familiar with SSH tunneling in general, so it's hard for me to say what effect would VPN (or anything else you might have there; a firewall?) or similar have on it.

I am unsure whether there is a firewall. I will try this same thing on another Linux server I have access to.

I like ptvs more than pyCharm for some reasons :) but...
It's a shame ptvs do not implement "remote debugging over an SSH connection" like pyCharm. I work a lot with boards like "Raspberry Pi" and I do not like to install a remote debugger server tool, and edit my modules with some special code, for such a task.

Was this page helpful?
0 / 5 - 0 ratings