9

Is it possible to connect SSH within VS Code (for MacOS) to my AWS instance?

I would like to use it the same way I do with docker containers. Modify my code inside the AWS instance and use the same compute power.

Thanks

2
  • Have you tried it? What error/problem are you receiving? Commented Jul 12, 2019 at 0:50
  • I just don't know the steps to start the connection. Could you please explain? Commented Sep 6, 2019 at 8:13

2 Answers 2

11

HOW TO CONNECT TO AWS INSTANCE (EC2)

  1. Open Visual Studio Code and install extension - 'Remote - SSH'
  2. After installation click the green link icon bottom left of the VSC to 'Open a remote window'
  3. Select 'Remote-SSH: Connection to host...
  4. Add new SSH host
  5. Type ubuntu@hostname_or_ip
  6. Select the '/root/.shh/config'
  7. Edit the config file

See my example

#Read more about SSH config files: https://linux.die.net/man/5/ssh_config

Host <enter hostname>
    HostName <enter hostname>
    User ubuntu
    IdentityFile ~/.ssh/mypemfile.pem 

  1. Save and connect by clicking the link to 'open a remote window' and select your saved configuration.
6

SOLVED

The steps are:

1 - Create your instance (let's say a EC2 t2.micro from the Ubuntu18 image)
2 - Create a ssh configuration file (let's call it ssh_config_aws)
3 - Following the steps in the doc:

Host
    User ubuntu (ec2-user if you use Amazon IMA)
    HostName
    IdentityFile

Then you will see the connection available in the menu of Remote Connections Plugin.
Simply connect to it and your Visual Studio Code window will attach to the running instance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.