Virtual Geek

Tales from real IT system administrators world and non-production environment

configure remote ssh extension on visual studio code

In my earlier article I wrote How to Setup Passwordless SSH Login on Windows to ease my tasks, to connection between Windows to Linux and this is a second part of the article. I use visual studio code to write my all devops codes, most of the time whenever I want to test the script on linux, free tools putty and scp are very handy. But for same server frequent connections I use VSCode extension Remote - SSH from Microsoft marketplace. It can be used it as complete open source SSH/SCP tool. It works as a remote gui tool for ssh.  

To start with VSCode go to extensions, Search for ssh on the marketplace, Remote - SSH extension from Microsoft is the popular one and will list first with most downloaded  extension. Install it and reload VSCode, You will find related extension Remote - SSH: Editing Configuration Files is also installed with it.

visual studio code remote - SSH  remote -ssh explorer editing configuration vscode extensions marketplace enabled windows 10 login to ssh.png

New Icon will appear on left navigation pane, click it. As no SSH hosts have been configured yet, press Plus + button to add linux SSH targets, 

visual studio code vscode remote ssh configuration remote explorer SSH targets No SSH hosts have bene configured yet remote-ssh add ssh host.png

Enter SSH connection command information as below on the popped up textbox and press Enter. Change user@IP_FQDN as per your requirement.

ssh [email protected] -A

Next select SSH configuration file to update, choose <UserProfileFolder>\.ssh\config and press Enter, Once the Host is added, In the bottom one gui box will popup to connect, If you open config file you will see new configuration is added.

virtual studio code remote ssh vscode enter ssh connection command ssh root@ -a enter profile .ssh config file ssh_config programdata seeting host remote -ssh extension open config connect.png

VS code remote ssh could not establish to host, connecting was canceled

User specific file is located at location <UserProfileFolder>\.ssh\config and can be opened with notepad.

.ssh config visual studio code vscode remot -ssh configuration remote devlopment over ssh config host file forwardagent ssh_config windows system.png

Global ssh configuration file located at location C:\ProgramData\ssh\ssh_config file, these can be opened in notepad and has easy yml/yaml format.

Host <DisplayName>
  HostName <IP address or FQDN>
  User <UserName>
  ForwardAgent yes  

To connect to the SSH target choose it and click on connect icon. If you haven't followed How to Setup Passwordless SSH Login on Windows, while connecting it will prompt for ssh user password.

REMOTE EXPLORER visual studio code vscode remote -ssh config script .ssh userprofile ssh_config forwardagent hostname user root host ssh passwordless configuration with public private key ssh authorised keys.png

Next it will open another visual studio code in separate window, on the bottom you will see message setting up ssh host IP/FQDN:(details) Initializing VS Code Server. By clicking details you can see the logs in OUTPUT, once the connection is successful it will ask to open a folder on remote linux server. Also in the bottom connection is made over SSH to linux.

Now you can easily execute bash command in terminal, drag and drop file and folder on the explorer, plus files/folders can be created, added, edited, deleted and executed with alone VSCode.

visual studio code vs code ssh connection remote - ssh extension from marketplace remotely edit linux file from vscode Visual Studio Code Remote Development over SSH passwordless ssh key keygen.png

Useful Articles
Docker Error response from daemon i\o timeout internet proxy
Cannot connect to the Docker daemon at unix:var run docker.sock. Is the docker daemon running
How to install Docker on Linux
How to install Ansible on Linux for vSphere configuration

Go Back


Blog Search

Page Views


Follow me on Blogarama