vscode-debuggervscode-remote

VSCode: How to connect to Remote SSH Host, inside an SSH Host?


I have hardware available through my university jump host, to which I connect to through ssh:

$ ssh username@login.university.edu
Password: *******

$ ssh hardware1
Password: *******

[my_computer] --> [login.university.edu] --> [hardware1]


I can get a window to login.university.edu with VSCode Remote SSH Connect to Host, but then once there I use the terminal to SSH into hardware1, therefore I can't use the debugger on hardware1.

How could I get a window to hardware1? Or else how can I customize launch.json in order to run ssh hardware1 and input my password?


Solution

  • This one works for me with Flask debugging.

    On your laptop:

    Host university
        HostName login.university.edu
        User username
        IdentityFile ~/.ssh/university_key
    
    Host hardware1
        HostName hardware1
        User username
        IdentityFile ~/.ssh/hardware1_key
        ProxyJump university
    
    cd ~/.ssh
    ssh-keygen -f university_key # enter - enter
    ssh-copy-id -i university_key.pub username@login.university.edu
    

    On your jump server

    cd ~/.ssh
    ssh-keygen -f hardware1_key # enter - enter
    ssh-copy-id -i hardware1_key.pub username@hardware1.university.edu # if this isn't copy the key try username@hardware1
    

    Two files created in the folder: hardware1_key and hardware1_key.pub Copy this two file to your local (laptop) ~/.ssh folder.

    Now you can login

    If you are able to connect from CLI to your hardware1, open the VS Code.
    If not, your hardware1_key.pub is not copied to hardware1, try to fix this one: username@hardware1.university.edu <- this is maybe wrong

    On VS Code

    Check your ~/.ssh/config file

    Press CTRL+SHIT+P Choose Remote-SSH: Open SSH Configuration file... From the dropdown menu choose your config file: ~/.ssh/config Check if everything right (must be... if you can login from CLI)

    Connect to host

    Now you can use even debug mode, but the interpreter must be installed on the host you connected.
    For example if you want debugging a Python code on hardware1,
    you need to install Python 3.7 or higher on hardware1...