The Remote VSCode extension made it easy to open individual files residing on a remote computer using SSH in VSCode. However, opening invidividual files like this is not an ideal workflow when working on a project or directory of files.
The Remote - SSH extension makes opening and working with remote directories just as natural and fully-featured in Visual Studio Code as working with local directories. Once you set it up and have a remote directory open, you can browse the directory tree, open any files, find-replace and lookup definitions across all the files.
To use this:
ssh joe@remote123command and then the path on the remote computer. VSCode will prompt you for the password on the remote computer.
To stop using password:
You will notice that VSCode asks for the remote password every time you open the remote directory or reopen VSCode. To avoid this, we need to understand how VSCode uses ssh and then provide the ssh client with an identity file as follows:
C:\Windows\System32\OpenSSH\ssh.exefor its SSH operations.
By default, when you added a single remote computer, it would have these lines:
Host 10.110.22.22 HostName 10.110.22.22 User joe
id_rsa.pubgenerated by the above step to the
id_rsa.pubis not really needed, since we have already shared it to the remote computer in the earlier step.)
id_rsain the above directory, so now you should be able to open remote directory at will without entering the password.
To make this explicit (in case you want to use a different path or filename), you can add an
IdentityFile line to the SSH config file like this:
Host 10.110.22.22 HostName 10.110.22.22 User joe IdentityFile ~\.ssh\id_rsa
Note how the OpenSSH Windows client can understand
~ to mean
%USERPROFILE, but needs Windows forward slashes in the path.
Tried with: Visual Studio Code 1.47 and Windows 10