Recently I setup an Amazon EC2 Ubuntu Server instance and wanted to connect it to the awesome Cloud 9 IDE. I was sick of interacting with a server through terminal windows.
Use this link and get $19 free credit with Cloud 9: https://c9.io/c/DLtakOtNcba
Cloud 9 IDE (sample screenshot)
Previously I was using Digital Ocean (my Digital Ocean setup guide here) and this was simple, you get a VM and you have a root account and you do what you want. Amazon AWS however, have extra layers of security that prevent logging in as root via SSH and that can be a pain with Cloud 9 as your workspace tree is restricted to the ~/ (home) folder.
Below are the steps you need to connect to an AWS instance with user “ubuntu” and “root” with Cloud 9.
Connecting to an AWS instance with Cloud 9 as user “ubuntu”
1. Purchase and set-up your AWS instance (my guide here).
2. You need to be able to login to your AWS server from a terminal prompt (from OSX). This may include opening port 22 the AWS Security Group panel. Info on SSH logins here.
3. On your AWS server (from step 2) Install NodeJS.
You will know node is installed if you get a version returned when typing the following bash command.
node -v
tip: If node is not installed you can run the Cloud 9 pre-requisites script (that includes node).
curl -L https://raw.githubusercontent.com/c9/install/master/install.sh | bash
4. Ensure you have created SSH key on Cloud 9 (guide here).
5. Copy your Cloud 9 SSH key to the clipboard.
6. On your AWS server (in step 2) edit the ~/.ssh/authorized_keys file and paste in the Cloud 9 SSH key (after you AWS key pair that was added from the setup of AWS) to a new line and save the file.
7. Log in to Cloud 9 and click create Workspace then Remote SSH Workspace.
- Name your workspace (all lowercase and no spaces).
- Username: ubuntu
- Hostname: Add your AWS ec2 server hostname.
- Initial Path: This has to be ~/
8. Click Create Workspace
9. If all goes well you will have a prompt to install the prerequisites.
If this fails check out the Cloud 9 guide here.
Troubleshooting: I had errors like “Project directory does not exist or is not writable and “Unable to change File System Path in SSH Workspace” because I was trying to set the workspace path as “/” (this is not possible on AWS with the “ubuntu” account.
10. Now you should have a web-based IDE that allows you to browse your server, create and edit files, run termials instances that will reconnect if your net connection or browser tab drops out (you can even go to a different machine and continue with your session).
Connecting to an AWS instance with Cloud 9 as user “root
Connecting to your server as the “ubuntu” server is fine if you just need to work in your “ubuntu” home folder. As soon as you want to start changing other settings outside of your home folder you are stuck. Granting “ubuntu” higher privileges server wide is a bad idea so here is how you can enable “root” login via SSH access.
WARNING: Logging in as ROOT IS BAD, you should only allow Root Login for short periods and it is advisable to remove root login abilities as soon as you do not need them or in production.
Having root access while developing or building a new server saves me bucket loads of time so lets allow it.
1. Follow step 1 to 5 in the steps above (setup AWS, ssh access via terminal, install node, create cloud 9 ssh key, copy the cloud 9 ssh key to the clipboard).
2. SSH to your AWS server and edit the following file:
Save.
3. Backup your root authorised keys file
4. Edit the root authorized_keys file and paste in your Cloud 9 SSH Key.
5. Now you can create a Cloud 9 Connection to your server with root
- Name your workspace (all lowercase and no spaces).
- Username: root
- Hostname: Add your AWS ec2 server hostname.
- Initial Path: This has to be /
tip: If you have not added you SSH key correctly you will receive this error when connecting.
6. You should now be able to connect to AWS ec2 instances with Cloud 9 as root and configure/do anything you want without switching to shell windows.
Security
As a precaution, do check your website often in https://www.shodan.io and see if it has open software or is known to hackers.
Enjoy
If this guide has helped please consider donating a few dollars.
Donate and make this blog better
Ask a question or recommend an article
[contact-form-7 id=”30″ title=”Ask a Question”]
V1.6 security