Update and install software when EC2 VM is initializing #EC2AWS
How to update and install software when EC2 instance is created ?
Login to AWS.
- Go to EC2.
- Choose „Launch Instance” button
- In the left menu select Community AMIs.
- Select Ubuntu from „Operating system”
- On right panel click on „Select” button on right side of Ubuntu 16.04 ( This tutorial was tested on this distro)
- Choose an Instance Type – there is problem with NoMachine on t2.mico – I suggest you choose 2 vCPUs and 2 GB memory as minumum.
- Select „Next: Configure Instance Details”
- In Step 3: Configure Instance Details, scroll to bootom and select „Advanced Details”
- In „User data” windows past your script.
- Select „Next: Add Storage”
- Select „Next: Add Tags”
- Select „Next: Configure Security Group”
- 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.
- Select „Review and Launch”
- Select „Launch”
- 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.
- Press „Launch Instance”
- Select View Instances
- 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