Forum Navigation
You need to log in to create posts and topics.

Visual Studio Code – SSH Keys not working

Visual studio code allows to you to do remote development with SSH Targets. but every time you connect to remote machine or session gets disconnected VScode prompts for password. all the tutorials seems to show easy exchange SSH keys in order to avoid the password prompt but its not working!!! when you are on windows trying to connect to Linux machine. even if you are using WSL (Windows Subsystem Linux) you can encounter this problem when trying to connect with SSH key exchange

The Problem

Main reason is when you doing ssh-copy-id from Windows to Linux Machine it adds extra values for the hostname in  $HOME/.ssh/authorized_kyes Example: ecdsa-sha2-nist…………………..JOWuiA== root@MyLovelyPC-2020-09-04


order to fix it copy the SSH public key manully

run the following commands on your windows machine (either in WSL or install ssh utilities)

ssh-keygen -t rsa -b 4096
scp .ssh/ username@

ssh to remote host

cd .ssh/
cat ../ >> authorized_keys

NOTE: This issue is relevant not just for VScode but also to any remote development without password

if you are using WSL linux on your windows machine. open your SSH config in Visual Studio code and in the host add the following lin

ForwardAgent yes
PreferredAuthentications publickey
IdentityFile ~\\.ssh\\id_rsa

Make sure the following permissions are set

.ssh folder: 700 (drwx——)
public key: 644 (-rw-r–r–)
private key: 600 (-rw——-)

chmod g-w /home/user
chmod 700 /home/user/.ssh
chmod 600 /home/user/.ssh/authorized_keys


if you generated your ssh keys inside WSL linux. make sure also to copy them to your home user directory

cp ~USERNAME/.ssh/id_rsa* /mnt/c/Users/USERNAME/.ssh

and set proper permissions


All content available through this Web Site is provided on an “AS IS” and “AS AVAILABLE” basis, with all faults. Tracston LTD makes no warranty or representation with respect to the quality, accuracy, or availability of the Web Site or any of its content.