Skip to content

Instantly share code, notes, and snippets.

@asalhani
Last active December 15, 2019 16:57
Show Gist options
  • Save asalhani/cd2d62aa9e7134afd5fac8644a8447a9 to your computer and use it in GitHub Desktop.
Save asalhani/cd2d62aa9e7134afd5fac8644a8447a9 to your computer and use it in GitHub Desktop.
Configure Visual Studio Code (VS Code) to connect remotely to Linux (SSH)

Configure Visual Studio Code (VS Code) to connect remotely to Linux (SSH)

Source

VS Code Remote Development

1- Check to see if you already have an SSH key on your local machine C:\Users\your-user\.ssh\id_rsa.pub if not, create new key (Powershell cmd)

ssh-keygen -t rsa -b 4096

2- copy create key from local (Windows) into remote (Linux) by running below commands (Powershell cmd)

$REMOTEHOST="your-user-name-on-host@host-fqdn-or-ip-goes-here"

scp "$env:USERPROFILE\.ssh\id_rsa.pub" "${REMOTEHOST}:~/tmp.pub"
ssh "$REMOTEHOST" "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat ~/tmp.pub >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && rm -f ~/tmp.pub"

Note: In VS Code, if you have the following error message while connecting the remote server, follow the below link to fix the issue:

Fix Link

Issue:

Bad owner or permissions on C:\\Users\\<user>/.ssh/config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment