Menu

Virtual Geek

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

Connecting to Ubuntu Linux from Windows Using VS Code Remote SSH

This is a step by step guide to setting up Visual Studio Code - Remote SSH. This helps to connect to Linux system remotely and add, edit, delete files and folder with Visual Studio code, at the same time I can execute script files. This helps to manage Linux and use it as all in one tool for DevOps activities. As VS Code is open source tool and SSH extension is free (Author Microsoft), I don't have to pay for any other commercial tools.

How to connect VS Code to Ubuntu Linux via SSH private key authentication from Windows network

To start configuration, I am on my windows system. and created a ssh key using command ssh-keygen -t ed25519. This creates public and private keys inside current user profile folder inside .ssh folder. We will need .pub extension key contents which I will copy and paste on Linux server.

To view the content of file use command - cat C:\Users\UserProfile\.ssh\id_ed25519.pub.

Screenshot showing ssh-keygen configuring and creation ssh keys on microsoft windows sha256 key pub

Next go to remote Linux server use the key and add it to ~/.ssh/authorized_keys file. You can use below command to add information.

echo 'Your SSH key username@computername'  >> ~/.ssh/authorized_keys

screenshot on remote linux where adding windows ssh key rsa ed25519 in .ssh authorized_keys

Once key is added on Linux, I am back on windows system. I have Visual Studio code is already installed. Go to Extension view, Search for ssh in the Marketplace. Install Remote - SSH and related extensions from the list and Microsoft is the author developer for these extensions.

Screenshot of showing configuration of windows vscode remote ssh extension from marketplace as editor for linux ssh

Next you will see the remote connection icon appeared on the left hand side, once the Remote SSH extension is installed. On the SSH click settings  icon to Open SSH config file (C:\User\UserProfile\.ssh\config), Add below information in the config file.

Host Ubuntu001
    HostName 192.168.34.90
    User vjanvi
    IdentityFile C:\Users\UserProfile\.ssh\id_ed25519

screenshot showing ssh configuration on vs code with remote tunnel extension hostname and indentityfile editor to linux server vs code server configuration

Configuration is completed, You will see Linux server is added to the SSH section, Click connect in new windows.

screenshot Microsoft Visual Studio Code remote tunnel ssh extention connect in new windows linux configuration

This is the last screenshot that shows I am connected to Linux server over VS Code Terminal from windows. In the left pane I have opened a remote Linux folder and can Add Edit or delete files on the go.

Screenshot of showing microsoft vistual studio code (vscode) with linux ssh terminal and editor in one screen configuration for devops

Useful Articles
How to switch to other Azure AD tenant using PowerShell and Azure CLI
Creating a new user in Azure AD using oneliner PowerShell and Azure CLI
Connect-AzureAD: One or more errors occurred. Could not load type 'System.Security.Cryptography.SHA256Cng'
Create a Azure Virtual Network with Subnet using PowerShell
Azure add create a Subnet to existing Virtual Network using PowerShell
Remove Azure Virtual Network Subnet using PowerShell
Create key vault and secrets with access policies in Microsoft Azure
Working With Azure Key Vault Using Azure PowerShell and AzureCLI
Use Key Vault secret identifier url to get the secret value using Powershell
Use a Azure VM system assigned managed identity to access Azure Key Vault
Create Azure Key Vault Certificates on Azure Portal and Powershell
Export certificates from Azure Key Vault using PowerShell

Go Back

Comment

Protected by Mathcha

Blog Search

Page Views

1 5 5 5 7 3 0 6

Archive

Follow me on Blogarama