How to Remote — SSH Using VS Code

SSH into server & access its directory also we can directly attach debugger to the app.it will be very useful for debugging app’s in production

Saurabh Gangamwar
2 min readMar 5, 2021

1. Install Remote SSH Plugin for VS Code

2. Add SSH Targets

3. Enter full ssh command with key for example

ssh -i "/Users/saurabh/Downloads/aws-demo.pem" ubuntu@43.46.73.220

first try you ssh command in cmd / terminal

select first option to save the configuration

Congo you have successfully SSH into remote server 🎉

now we access the file system of the server & also we can run the app in debug mode.attach debugger to that process. if you want to know how to attach debugger to the nodeJs apps. let me know in the comment section.

Troubleshooting

SSH key permission issue fix for Windows

if you get this error on windows

C:\>ssh ubuntu@192.168.0.1 -i private-key.ppk
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for 'private-key.ppk' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "private-key.ppk": bad permissions
ubuntu@192.168.0.1: Permission denied (publickey).

set this permission on SSH key file

icacls .\\private.key /inheritance:r 
icacls .\\private.key /grant:r "%username%":"(R)"
#example command
#icacls .\aws-demo.key /Inheritance:r
#Icacls .\aws-demo.key /Grant:r "SaurabhGangamwar":"(R)"

Windows SSH: Permissions for ‘private-key’ are too open

--

--

Saurabh Gangamwar

Full stack developer @Stryker. Loves building SAAS products using @angular ❤ @nestJs 🚀 @mysql