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:
Issue:
Bad owner or permissions on C:\\Users\\<user>/.ssh/config