Code Yarns β€πŸ‘¨β€πŸ’»
Tech Blog ❖ Personal Blog

Work with remote directories in VSCode using Remote SSH

πŸ“… 2020-Jul-14 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ ssh, vscode ⬩ πŸ“š Archive

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.

This is in contrast to the Remote VSCode extension which made it easy to open individual files residing on a remote computer using SSH, but was not ideal for larger-scale work like working on a project or directory of files.

Usage

To use this:

Use without 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:

Host 10.110.22.22
  HostName 10.110.22.22
  User joe
Host 10.110.22.22
  HostName 10.110.22.22
  User joe
  IdentityFile ~\.ssh\id_ed25519

Note how the OpenSSH Windows client can understand the Unix ~ to map to %USERPROFILE, but needs Windows forward slashes (not the Unix back slashes) in the path.

After this setup, you should be able to connect to the remote host and open directories on it just like they were on the local computer.

Tried with: Visual Studio Code 1.47 and Windows 10


Β© 2023 Ashwin Nanjappa β€’ All writing under CC BY-SA license β€’ 🐘 Mastodon β€’ πŸ“§ Email