Update and install software when EC2 VM is initializing #EC2AWS


How to update and install software when EC2 instance is created ?

Login to AWS.

 

  1. Go to EC2.
  2. Choose „Launch Instance” button
  3. In the left menu select Community AMIs.
  4. Select Ubuntu from „Operating system”
  5. On right panel click on „Select” button on right side of Ubuntu 16.04 ( This tutorial was tested on this distro)
  6. Choose an Instance Type – there is problem with NoMachine on t2.mico – I suggest you choose 2 vCPUs and 2 GB memory as minumum.
  7. Select „Next: Configure Instance Details”
  8. In Step 3: Configure Instance Details, scroll to bootom and select „Advanced Details”
  9. In „User data” windows past your script.
  10. Select „Next: Add Storage”
  11. Select „Next: Add Tags”
  12. Select „Next: Configure Security Group”
  13. In this step you must add rules to firewall to port 4000, it’s needed for Nomachine. Select „Add Rule” button.  Leave Custom TCP in Type and TCP in Protocol write 4000 in Port Range, Choose Custom in Source and change for Anywhere. This option is potential risk because everyone can connect to you instance, you can change it for your client IP.
  14. Select „Review and Launch”
  15. Select „Launch”
  16. In „Select an existing key pair or create a new key pair” choose „Create a new key pair” and write name of key and press „Download Key Pair” save key. It’s very important for you, without this key you can’t connect to this VM.
  17. Press „Launch Instance”
  18. Select View Instances
  19. After a few minutes you can connect to your VM desktop.

 

 

 

#!/bin/bash

sudo apt-get -y update

sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o DPkg::options::=”–force-confdef” -o DPkg::options::=”–force-confold”  install grub-pc

sudo apt-get -y upgrade

export DEBIAN_FRONTEND=noninteractive

sudo -E apt-get update

sudo -E apt-get install -y ubuntu-desktop

wget http://download.nomachine.com/download/6.0/Linux/nomachine_6.0.78_1_amd64.deb -P /home/ubuntu/

sudo dpkg –install /home/ubuntu/nomachine_6.0.78_1_amd64.deb

mkdir /home/ubuntu/.nx

mkdir /home/ubuntu/.nx/config

touch /home/ubuntu/.nx/config/authorized.crt

cat /home/ubuntu/.ssh/authorized_keys >> /home/ubuntu/.nx/config/authorized.crt

 

Script works for last free Nomachine package nomachine_6.0.78_1_amd64.deb!


Kategoria: Bez kategorii

Możliwość komentowania została wyłączona.