DEV Community

Brandon Wie
Brandon Wie

Posted 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
Earlier Windows Install
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


💡 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.

Top comments (1)

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.