Write and execute code directly in remote machines using VS Code
Access remote machines, develop and execute code in it, read log files, everything directly from VS Code using the most useful plugin "Remote-SSH"

Access remote machines, develop and execute code in it, read log files, everything directly from VS Code using the most useful plugin "Remote-SSH"
Introduction
Now most of the developers using Visual Studio Code for development. And it provides various plugin to make developers code comfortably. I am writing this blog about one of my favourite plugin Remote - SSH which I am using every time to update code in remote server and check logs by running grep command in large log files and export the required contents in separate file and view easily. All these things can be done directly from the Visual Studio Code instead of connecting through a Putty terminal.
Installation & Configure
Install Remote - SSH from the Microsoft marketplace. After successful installation, You can find the "Remote Explorer" icon in the left navigation.

After installing the plugin, we need to create a config file with the list of remote server details which you wish to connect.Create a file in the below mentioned path with name sshConfig (without any extension)
Note : If you didn't have
.sshfolder create new folder and enter name as.ssh.and save it
C:\Users\<your-username>\.ssh\sshConfig
Provide the remote server details inside the sshConfig file in the below mentioned format
Host dev
HostName XXX.XX.XX.XXX
User ubuntu
IdentityFile "C:/Users/boopathikumar/.ssh/ubuntu.pem"
Host prod
HostName XXX.XX.XX.XXX
User ubuntu
IdentityFile "C:/Users/boopathikumar/.ssh/ubuntu.pem"
Meaning of the terms used in the above format is explained below
Host- Provide any name for your remote server for further reference.Hostname- Remote server Ip addressUser- Username for login into the serverIdentityFile- Path of you pem key
Then select the settings icon near SSH TARGETS and add the sshConfig file path which we had created previously.

After that you can see the list of remote servers configured in the sshConfig file inside the Visual Studio Code as shown below

Connect server
To connect to any particular server, Click on the folder icon next to the remote server name as highlighted below.

Then, Select the Operating system of the remote server.

Once the server is connected, You can see the name of the host which you provided on sshConfig file on the bottom left corner.
Click on Open folder button to view the folders in the remote server.Select the folder that you need to view as shown below

After that you can view files under selected remote folder on the explorer as shown below.

Also you can use the integrated terminal to run the commands on connected remote server directly.
Setup "Remote - SSH" and enjoy programming in a remote server directly from Visual Studio Code !!!.

