Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSH into AWS Cloud9 Environment

I would like to SSH into my Amazon Web Services (AWS) Cloud9 Elastic Cloud Compute (EC2) environment, but there is no key pair assigned to the Cloud9 EC2 environment. How can I assign a key pair to that environment, so that I can SSH into it?

I created the AWS Cloud9 EC2 environment through the Cloud9 interface, rather than creating the EC2 environment and then accessing it through Cloud9. When I create EC2 environments normally, I am given the opportunity to assign an existing key pair, or create a new key pair. This option was not presented to me when I created the environment through Cloud9.

like image 651
Sean McCarthy Avatar asked Dec 31 '18 18:12

Sean McCarthy


1 Answers

You can SSH into a Cloud9 environment created through Cloud9. The steps are similar to sharing a running app over the internet in the docs, but instead of sharing the app, you share the SSH server.

  1. In AWS Console, find the corresponding EC2 instance.

  2. In the bottom panel, under the Description tab, in Security groups row, click on the link to go to associated security group.

  3. You should now be in Security Groups section. In the bottom panel, under the Inbound tab, click Edit and add:

    • Type: SSH
    • Source: Anywhere

    and click Save.

  4. In Cloud9 terminal, add your public key to ~/.ssh/authorized_keys. Don’t replace the existing keys or elsewise Cloud9 IDE wouldn’t be able to connect to the instance.

  5. You can now SSH into the Cloud9-managed instance using ssh ec2-user@<ip>, or ssh ubuntu@<ip> if using Ubuntu AMI, for other AMIs see default user name for the AMI

like image 186
Thai Avatar answered Sep 18 '22 14:09

Thai