DEV Community

Cover image for Connect VSCode and EC2 using SSH
Brandon Wie
Brandon Wie

Posted on • Edited on

Connect VSCode and EC2 using SSH

I assume that you have VSCode installed.

1. Install an OpenSSH compatible SSH client

OS Instructions
Windows 10 1803+ / Server 2016/2019 1803+ Install the https://learn.microsoft.com/windows-server/administration/openssh/openssh_install_firstuse.
Earlier Windows Install https://git-scm.com/download/win.
macOS Comes pre-installed.
Debian/Ubuntu Run sudo apt-get install openssh-client
RHEL / Fedora / CentOS Run sudo yum install openssh-clients

💡 If you do not have a SSH host set up, follow the directions for LinuxWindows 10 / Server (1803+), or macOS or create a VM on Azure.

2. Install Remote - SSH extension on VSCode

VSCode Market Place Link

3. Configure

  1. Open command palette: cmd + shift + p
  2. Select **Remote-SSH: Open SSH Configuration File**
  3. Select one of your config location, I’ll just pick the first one

Select SSH configuration

  1. Update the values

    Host alias-you-will-use
        HostName Public-IPv4-DNS-of-Your-EC2-instance
        User ec2-user # default user name
        IdentityFile path/to/your/pem/file
    

Note

💡 When you create a new EC2 instance, you create a new Key pair and the pem file will be automatically downloaded via the browser.

EC2 setup key pair

4. Connect

  1. Open command palette: cmd + shift + p
  2. Select Remote-SSH: Connect to Host
  3. You will find the alias you set on the list
  4. Select the alias
  5. (I didn’t have this case but,) when it connects, there’s a chance you see a prompt to enter a passphrase for the key
    1. Check out this video if it happens

5. Open File or Folder

You can click the Open Folder button on the explorer or press cmd + o to open file or folders you want to work with.

You can install other VSCode extensions in SSH.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (1)

Collapse
 
brandonwie profile image
Brandon Wie • Edited

For those of you who are using small instances such as t3.micro, you might face the container shutting down because of high CPU usage. Please go to VSCode settings and click your remote tab, and uncheck the Search: Follow Symlinks. It helped me.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay