Visual Studio Code - SSH Keys not working
Quote from moshe on 17/10/2020, 6:55 amVisual 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
Solution
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/id_rsa.pub username@192.168.1.1ssh to remote host
cd .ssh/
cat ../id_rsa.pub >> authorized_keysNOTE: This issue is relevant not just for VScode but also to any remote development without password
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
Solution
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/id_rsa.pub username@192.168.1.1
ssh to remote host
cd .ssh/
cat ../id_rsa.pub >> authorized_keys
NOTE: This issue is relevant not just for VScode but also to any remote development without password
Quote from moshe on 13/11/2020, 7:36 amif 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
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
Quote from moshe on 13/11/2020, 9:40 amMake 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
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
Quote from moshe on 13/11/2020, 1:40 pmNote:
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
Note:
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