microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.61k stars 275 forks source link

Remote SSH: Support RemoteForward in Fowarded Ports view #2318

Open pd93 opened 4 years ago

pd93 commented 4 years ago

Description

VSCode currently only displays Remote SSH port forwards in one direction (LocalForward or ssh -L). Please consider adding support for RemoteForward or ssh -R.

Use case

I've recently started using this in order to develop with the Flutter framework remotely over SSH with the Android emulator running on my local machine and the Flutter SDK and VS Code extension running on the remote.

This is possible by running adb tcpip 5555 on your local machine (with an Android emulator running or phone plugged in via USB). You can then forward the ADB port (ssh -R 5555 127.0.0.1:5555) to the remote, run adb connect 127.0.0.1:5555 and VS Code picks up the device perfectly.

See example ~/.ssh/config below:

Host myhost
    HostName        x.x.x.x
    LocalForward    8000 127.0.0.1:8000
    LocalForward    1433 127.0.0.1:1433
    RemoteForward   5555 127.0.0.1:5555

How it looks now:

image

Shosta commented 3 years ago

Hello, this is something that I would love to have inside VSCode for remote development. How can we upvote it ? Is it only with a 👍🏼 on the issue ? Or is there some more formal process ?

PavelSosin-320 commented 3 years ago

Do you mean --expose option in addition to -p ? [docker run --expose] (https://docs.docker.com/engine/reference/commandline/run/#publish-or-expose-port--p---expose)

iainvm commented 3 years ago

@PavelSosin-320 I think this issue is more about Remote - SSH extension, where what you're talking about is docker containers. Which would maybe be useful for the Remote - Containers extension but not SSH.

pd93 commented 3 years ago

I have updated the title to better reflect that this is request is specifically for Remote SSH, not Containers or WSL.

GuillaumeDesforges commented 3 years ago

Landed here because I also need it for mobile development, but handling "ssh -R" sounds like a good idea anyway, not too far from how "ssh -L" is done anyway (maybe?).

pd93 commented 3 years ago

@Shosta This issue has nothing to do with Docker or ADB. I simply used ADB/Flutter as an example of a use case for the requested feature. While I appreciate the steps you've outlined in your comment might be useful for some, I'm not sure that this is the right place for it as it could confuse users who are coming here trying to get Remote SSH working.

Shosta commented 3 years ago

Yes sure. If it is only related as an exemple.

Sorry for that.

GuillaumeDesforges commented 3 years ago

This feature request has not yet received the 10 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation.

Happy Coding

What about now? 🚀

sl45sms commented 3 years ago

+1, please that is really usefull, as a workaround, I've open the ports using wsl1

davystrong commented 3 years ago

I know the original example is for remote SSH, but this would also be useful for containers. May not be best practice, but I was developing something in a container, moved it to a remote server, but still wanted to connect to it from a test script in the local container. The remote port is automatically forwarded to my local PC but I can't access it directly from the container.

EirikFA commented 2 years ago

This might be unrelated, but I was curious on how you managed to run Flutter on an emulator/physical device while developing remotely through SSH. I have managed to connect my device to ADB on the remote server, but flutter run never finishes connecting to the VM service and observatory, while VS Code debug simply results in a black screen on my device.

pd93 commented 2 years ago

@EirikFA its definitely not the simplest setup. However, once you get the hang of it, it is really quite nice to work with. I actually realised there were a couple of mistakes in my OP (now updated). Here's some steps/tips to get you started:

Steps:

  1. Ensure that you have the following installed on your local machine:

    • Android Studio (and emulator stuff)
    • sdktools (adb in particular)
  2. Ensure that you have the following installed on your remote machine:

    • sdktools (adb in particular)
  3. Ensure that you have forwarded your port (in my case, I use 5555)

    Host myhost
       User            myuser
       HostName        x.x.x.x
       RemoteForward   5555 127.0.0.1:5555
  4. Start up a physical/emulated device (if physical, connect it via usb)

  5. In your local terminal (powershell etc.):

    • adb devices
    • You should see your device listed
    • adb tcpip 5555 (restarts the debugger in TCPIP mode on port 5555)
  6. Load up VSCode (it should now remote forward the port for you)

  7. On your remote terminal:

    • adb connect 127.0.0.1:5555
    • adb devices
    • You should see your device listed
    • If you do, you should also see the device appear in the VSCode status bar and you can now debug as you would if it were a local device.

Tips:

p.s. I hope I haven't missed anything as I don't actually have this set up on my machine to test right now. Feel free to reply if you have any issues!

p.p.s If you're really adventurous, you can get wireless adb with a real device working! It's really puts a smile on your face to have your code on a remote dev machine auto-hot-reload onto a physical device with no cables!

EirikFA commented 2 years ago

@pd93 I see. I did in fact make it work with a physical device wirelessly, after making remote forwarding the ADB daemon and the VM service port (and specifying the latter and --dds-port).

liuwd8 commented 3 weeks ago

Hi, I also encountered this problem, is there any solution here?