Difference between revisions of "Aws-run"
From Bashlinux
(Redirected page to Running an AMI) |
|||
Line 1: | Line 1: | ||
+ | #REDIRECT [[Running an AMI]] |
||
− | __NOTOC__ |
||
− | = Running an AMI = |
||
− | |||
− | == Registering the AMI == |
||
− | The AMI must be registered with Amazon EC2 in order to run instances, to do this run the following command: |
||
− | |||
− | <pre><nowiki> |
||
− | # ec2-register bashlinux/bashlinux-general-server.fs.manifest.xml |
||
− | </nowiki></pre> |
||
− | |||
− | then the AMI will be registered and the command will yield the name assigned, for this case the name is: |
||
− | |||
− | <pre><nowiki> |
||
− | IMAGE ami-43ab4f2a |
||
− | </nowiki></pre> |
||
− | |||
− | If you cannot see the AMI name, you can try to run the following command |
||
− | |||
− | <pre><nowiki> |
||
− | # ec2-describe-images -o self |
||
− | </nowiki></pre> |
||
− | |||
− | and it will return a string with the details of each AMI into the ''bashlinux'' bucket |
||
− | |||
− | <pre><nowiki> |
||
− | IMAGE ami-43ab4f2a bashlinux/bashlinux-general-server.fs.manifest.xml 367161194499 available private i386machine |
||
− | </nowiki></pre> |
||
− | |||
− | |||
− | == Generating a Keypair == |
||
− | |||
− | One half of this keypair will be embedded into the instance created, allowing you to login securely without a password using the other half of the keypair. |
||
− | |||
− | Every keypair need a name, so we can use the name of the image and run the fullowing command: |
||
− | |||
− | <pre><nowiki> |
||
− | # ec2-add-keypair bashlinux-general-server-keypair |
||
− | KEYPAIR bashlinux-general-server-keypair 2c:34:d7:d0:44:c5:06:07:3e:36:d3:99:9e:69:f2:5c:2f:ed:ab:47 |
||
− | -----BEGIN RSA PRIVATE KEY----- |
||
− | MIIEpAIBAAKCAQEAmJ7Sl4k3FSXFHcpV0bluEcUcRXaOHEn+w3+zmnKe/dcbRh2lq+mYubQQl8hg |
||
− | xmbPbD70gW8PxIqoG7FJwy4cEQhibuAyC5Fl9AsGetaC91fyoIA/veNuj+abIWiYHtrp9yGKZjRo |
||
− | 6Y9k+Um4Jlc2V4li8ktqve3c1uxMoCCNGR0v4ZFTLoKQUrqNH2AVH8HFgC3fU9JmJxf4+bMCK9sw |
||
− | aLuBGDdSxObyRBPc1A+csli6s/35Y939lQ7eBB/Ox2OVnLiuRvCzqUuwDXx+G5RUjdGD9Rsy0q3J |
||
− | I3r/5WfbLMaRCaEYUWr6qlKEROIfOnI1/qsltwCsoGV5CuHAgMr6VQIDAQABAoIBAQCO8lse0cdE |
||
− | yG6am3PMDljYzfzP1t3+AxRaedZ395mQ+ZOzFXuhzBZfARd1gpmZ2pu2sDSEssha9t/DqEcFR7/D |
||
− | +E1xug1FpnaOoHD+RsK99qLqz5RkP4vDvmNYZEXuyG3RKZoeZkJJWCRkFTckuhTM4oJJnHeq0wpA |
||
− | R2zxoetmM+nr0XU8PBlku8PN0QHLysAp+NawgUA0UHoaWVE/l/0r/7ZOzgJHYgfZQKh+9fsjDbuO |
||
− | bNoEyAQNZlthnuKmwDoQN7dGCPVkSIZ1XhmAI+/OSj88+JScRkpdDZbq5i1BS5RFuT/xnUo5rMgh |
||
− | lMxOTcGI5aYnWjeCP7VKlkxChmkhAoGBAOBvH4WsQe9nyWruoO9bKYoYkv5lnmGcy68b4Vg+boHc |
||
− | mEX3i7NKwGsLx0YeKOk9mpaSEvrN16ecT4ua0BqK2lt6tnLkamgrBf0j2JK84aBqDi7XftIm6ZsN |
||
− | gihfE3eGCnfUu5SnhWtp6KMJ9ooFm9w+2rgh81G3WZB+Ct6yydfNAoGBAK4WAdgx6w8f9hcPneF6 |
||
− | /aJ32FU4Y5E1xVpw39/dh5ZBDC/+iqVsNhZmzX4geAkRknXoXwZ4SedDWBGWvWiq+fyT+2cbCmc2 |
||
− | uzJLNSm9QTpQL/XRaWg2PsZBNlyRI6fppLMLPkPDZgiaEl24GWNn1Zis/vZyWx6YF2IqeY8A7ZSp |
||
− | AoGAbjEBCA+AO/v4H4FUENDwfzX7jd30ujZSpwIITNwyQ548QTX+KCROfwBEcb/DFGlDqiPEH9HK |
||
− | zSdowsFa5X1BImMIizZsrAJbqWLdJYaJPMp1djglsyaZ0Z/7RLkRhMCSCS2wf5cUYZ2ZM9tjaXbB |
||
− | hIxztK4umfNsjQ3lZlvf0A0CgYBTtpt+dkq9xDXX0xet5THwncb2/B3NJ1lW626MvX/E/lS5A6Ny |
||
− | dv3vedIZc82lNsECWBLSDqgjQJwqIR3GJmn+Tr8XTsaK6aPNRKM1BiBGxWa6w8/3YBaBybw1eUn3 |
||
− | JgCgZKi1d1IqksSAMtZqmfT57T7SDh3JMYQVHa3E2cJluQKBgQCImIVXZbSC8yvjADt6SkDx0tQu |
||
− | 0OYLdAavg5dV9ftW9a/5hk01+iscqp5N30SJIwgOYDWDPJwdztLjTuqdfFVg2VpKswb/8SnsOb9v |
||
− | OV/fvQHp+KxP6Ppjpxd1a7amAF2Kq+UMozXW9/iSZSKkVHiHwQjeLklFm5WOtpoW5OxvRQ== |
||
− | -----END RSA PRIVATE KEY----- |
||
− | </nowiki></pre> |
||
− | |||
− | then we create a file called `~/.ssh/bashlinux-general-server-keypair` and paste everything between (and including) the lines |
||
− | |||
− | `-----BEGIN RSA PRIVATE KEY-----` |
||
− | |||
− | and |
||
− | |||
− | `-----END RSA PRIVATE KEY-----` |
||
− | |||
− | To finish change permissions to the file |
||
− | |||
− | <pre><nowiki> |
||
− | # chmod 600 ~/.ssh/bashlinux-general-server-keypair |
||
− | </nowiki></pre> |
||
− | |||
− | |||
− | == Running an instance == |
||
− | The command to launch an instance is |
||
− | |||
− | <pre><nowiki> |
||
− | # ec2-run-instances ami-43ab4f2a -k ~/.ssh/bashlinux-general-server-keypair |
||
− | RESERVATION r-075c9f6e 367161194499 default |
||
− | INSTANCE i-ef79ad86 ami-43ab4f2a pending 0 m1.small 2008-06-20T01:36:56+0000 us-east-1b |
||
− | </nowiki></pre> |
||
− | |||
− | Then to check the status run: |
||
− | |||
− | <pre><nowiki> |
||
− | # ec2-describe-instances i-577aae3e |
||
− | RESERVATION r-9f5c9ff6 367161194499 default |
||
− | INSTANCE i-577aae3e ami-43ab4f2a ec2-67-202-23-7.compute-1.amazonaws.com domU-12-31-39-00-A2-02.compute-1 .internal running bashlinux-general-server-keypair 0 m1.small 2008-06-20T01:57:42+0000 us-east-1a |
||
− | </nowiki></pre> |
||
− | |||
− | where the name is `ec2-67-202-23-7.compute-1.amazonaws.com`. |
||
− | |||
− | === Authorizing Network access to the instances === |
||
− | Now that the image is running we need to authorize network traffic to the instance, run the following commands to accomplish with: |
||
− | |||
− | <pre><nowiki> |
||
− | # ec2-authorize default -p 22 |
||
− | GROUP default |
||
− | PERMISSION default ALLOWS tcp 22 22 FROM CIDR 0.0.0.0/0 |
||
− | # ec2-authorize default -p 80 |
||
− | GROUP default |
||
− | PERMISSION default ALLOWS tcp 80 80 FROM CIDR 0.0.0.0/0 |
||
− | </nowiki></pre> |
||
− | |||
− | |||
− | === Connect to the launched instance === |
||
− | Now that network is authorized you can connect using the following command: |
||
− | |||
− | <pre><nowiki> |
||
− | ssh -i bashlinux-general-server-keypair [email protected] |
||
− | </nowiki></pre> |
||
− | |||
− | |||
− | === Link Public IP Address to the instance === |
||
− | '''Allocating IP address''' |
||
− | Now that the instance is running it only has a private IP, in order to allocate an public IP address run the following command: |
||
− | |||
− | <pre><nowiki> |
||
− | # ec2-allocate-address |
||
− | ADDRESS 75.101.129.154 |
||
− | </nowiki></pre> |
||
− | |||
− | '''Associating IP address''' |
||
− | The IP address the gave us the above command must be added to the associate command as follows: |
||
− | |||
− | <pre><nowiki> |
||
− | # ec2-associate-address -i i-577aae3e 75.101.129.154 |
||
− | ADDRESS 75.101.129.154 i-577aae3e |
||
− | </nowiki></pre> |
||
− | |||
− | The instance can be now accessed typing in the browser `ec2-75-101-129-154.compute-1.amazonaws.com` |
Latest revision as of 23:07, 9 June 2015
Redirect to: