Host a secured Cloud 9 IDE on your Raspberry Pi


February 9, 2020

The cheapest way of having a secure, AWS hosted, real-time integrated development environment (IDE).

This how-to provides the step-by-step instructions to host the AWS Cloud9 IDE on a Raspberry Pi 3b+ with a secured shared environment through AWS at no additional cost to the users.

Why host Cloud9 IDE on a Raspberry Pi?

1. Cloud9 AWS Service is free! (Raspberry Pi is not)

Current pricing: https://aws.amazon.com/cloud9/pricing/

Raspberry Pi 3 B+ Purchase Cost

2. Raspberry Pi Power Cost

  • 5W max power consumption (5 Volt x 1 Amp = 5 Watts).
    • 5W’s is a worst case scenario, most Raspberry Pi’s average 2-3W’s during normal operation.
      * As an example, residential energy cost in Seattle is $ 0.0902 $ / kWhr for 2019 * http://www.seattle.gov/light/Rates/summary.asp
      • 24/7 operations = 8760 hours per year
      • Total Cost = 8760 hrs x $0.0000902 x 5 Watts = $3.95 per year!
      • Total cost of EC2.Micro (Default Cloud9) is $8.50 per month, or $102 per year. * $0.0116 per Hour * https://aws.amazon.com/ec2/pricing/on-demand/
    • Raspberry Pi’s operating cost is 4% of the cost of EC2 when operated 24/7. * Even when EC2 (T2.Micro) is only operated 4 hrs a day, the monthly costs are $1.85 or $22.20.

3. Processing power when compared to AWS EC2 T2.Micro default Cloud9 solution

  • The Raspberry Pi 3 B+ uses a Broadcom BCM2837B0, Cortex-A53 (ARMv8) 64-bit SoC @ 1.4GHz + 1 Gig SDRAM
    • (Default AWS EC2 Cloud9 Environment) T2.Micro = 1vCPU + 1 Gig Ram

Install Cloud9 on Raspberry Pi (Auto or Manual)

(Auto) SSH Script Installer

  • The SSH workspace type of Cloud9 IDE allows to connect the IDE to any SSH server. This repository contains the scripts to install all the required dependencies.

$ curl -L https://raw.githubusercontent.com/c9/install/master/install.sh | bash

Manual Installation

  • Installing cloud9sdk is simple, but may take time depending on the Raspberry Pi version you have. Log in to your pi and install git and nodejs if you don’t already have them installed:

$ sudo apt-get update

$ sudo apt-get install git nodejs

  • Next, use git to fetch cloud9sdk, move into the installed directory and run the install script:

$ git clone https://github.com/c9/core.git c9sdk

$ cd c9sdk

$ ./scripts/install-sdk.sh

  • Now create a workspace directory — this will be your root working directory (but don’t worry, you can link other directories into this one, or even add your /home directory to the file tree). I’m calling it environment in this tutorial:

$ mkdir environment

  • Start up the cloud9 server

$ nodejs ./server.js -p 8080 -l 0.0.0.0 -a name:passwd -w environment

  • This starts the server on port 8080, allows it to listen on all interfaces (not just localhost), sets a name:password for access (choose whatever you want here), and points the server to your workspace directory.

Configure AWS Cloud9 SSH Environment

Configure Guest AWS account

Configure DDNS Client for non-static home IP.

  • This is a best practice so that you do not inadvertently lose connection if your modem reboots or your ISP decides to flip your IP.

    • This Domain Name can be used in the AWS SSH configuration
  • Install DDClient

$ sudo apt-get install ddclient

  • Edit /etc/ddclient.conf
    • Only modify Login, Password, and Domain
    • If using NameCheap domain hosting, here is a sample configuration:
use=web, web=dynamicdns.park-your-domain.com/getip (http://dynamicdns.park-your-domain.com/getip)
protocol=namecheap
server=dynamicdns.park-your-domain.com (http://dynamicdns.park-your-domain.com/)
login=cyberforce.cloud (http://cyberforce.cloud/)
password='99999999999999999999999999'
@

Install Forever and configure

  • To keep your Cloud9 server up and running you can put it under control of the forever program:

$ sudo apt-get install npm

$ sudo npm install forever -g

$ cd ~/c9sdk

$ forever start server.js -p 8181 -l 0.0.0.0 -a name:passwd -w workspace

  • This will start up the server and supervise it in the background. You can find out more about forever at this site (https://github.com/foreverjs/forever).

  • Configure Cloud9 to survive restart/reboot using Forever, Script and Crontab

$ sudo su

$ crontab -e

  • Add this line to Crontab:

$ @reboot /home/pi/c9sdk/workspce/scripts/foreverscript.sh

  • ForeverScript.sh
#!/bin/sh
#export PATH=/usr/bin:/bin:/usr/sbin:/sbin
forever start /home/pi/c9sdk/server.js -p 8080 -l 0.0.0.0 -a cole:cole
echo "Computer was restarted at: $(date), and Cloud 9 was started again!" >> /tmp/cloud9.log

Secure inbound SSH connections

References

https://docs.aws.amazon.com/cloud9/latest/user-guide/welcome.html