SSH connent linux server on windows via VSCode
Secure Shell(SSH) is a cryptographic network protocol that provide a secure way to access and manage remote computers over an unsecured network.
1. Create a pair of keys:
Public key cryptographic is a common way to use SSH. To create a pair of public and private keys, we can use ssh-keygen program(may need to install git shell first on windows).
Type in the command ssh-keygen
and keep entering would generate a key pair using default settings, which would be stored as /home/$USER/.ssh/id_rsa(C:\Users$USER.ssh\id_rsa in windows).
2. Add public key to the remote server:
GitHub: Copy the content in .pub file, paste it to the SSH key part in your account setting.
VS Code: Install extensions for remote development. Copy the .pub file to target machine in ~/.ssh/authorized_keys.
Template:
1 2 3 4
Host ITX HostName 10.250.114.514 User lng205 IdentityFile "C:\Users\pc\.ssh\id_rsa"
3. Done:
use git@github.com:user/repo to acess GitHUb.
use the icon at bottom left to set up remote connection in VS Code.
If there’s an error, you can try to clear the /.ssh/known_host files.