I have hardware available through my university, to which I connect to through ssh in the following way in the command line:
ssh username@login.university.edu
//prompts for password
ssh hardware1
//prompts for password
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?
This one works for me with Flask debugging.
~/.ssh/config
and set your ssh connection
(on windows: c:\Users\username\.ssh\config
)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
ssh username@login.university.edu
login.university.edu
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.
ssh university
ssh hardware1 -v
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
~/.ssh/config
filePress 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)
Remote-SSH: Connect to Host...
university
or hardware1
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
...