Amazon EC2 簡易操作筆記 (使用 EC2 Console)

若只是要嘗鮮, 試試看而已, 就可以參考此篇試玩看看 (不過記得試完要記得關機, 不然錢會一直扣喔~)

此篇使用的是內建的管理工具 - Amazon EC2 Console (Web 界面)

在下面操作前, 還是建議此兩份資料要先看過:

此篇文章只做下面幾項:

  • 取得 Key Pairs (登入機器用)
  • 開新機器
  • 連線登入新機器
  • 強迫關機 / 重新開機

取得 Key Pairs (登入機器用)

  1. 登入 Amazon EC2 Console
  2. 左邊選單選: Key Pairs
  3. 點選上方 "Create Key Pair" 的按紐
  4. 輸入 Key Pair Name (假設輸入的 Name 是: YOUR_NAME)
  5. 就會產生 id-keypair-name.pem, 並跳出下載視窗, 將此下載儲存. 建議儲存在 "~/ec2-keys/id_YOUR_NAME" (以後要用 Firefox extension 時, 會自己讀這個目錄的此檔案)
  6. chmod 600 ~/ec2-keys/id_YOUR_NAME

開新機器

  1. 登入 Amazon EC2 Console
  2. 在 Getting Started 區塊: 點選 "Launch Instances"
  3. 選 "Community AMIS"
  4. 輸入 "Debian" 找到 Debian base install image:
    • alestic/debian-5.0-lenny-base-20081222.manifest.xml # 32 bits (玩 32 bits 可挑最低檔的機器, 比較便宜)
    • alestic-64/debian-5.0-lenny-base-64-20081222.manifest.xml # 64bits
  5. 表單填寫
    • Number of Instances: 1 (啟用一台機器)
    • Instance Type (64 bit): 機器種類
    • Key Pair Name: (Key Pair name)
    • Security Groups: 選定您設定的 Security Groups (不知道這是什麼, 可以參考: Amazon EC2 使用操作筆記 (使用 Elasticfox))
    • 點選 "Launch" 即可.
  6. 註: Security Groups 要記得開 SSH (22 Port)

連線登入新機器

  1. 於 My Resources 區塊: 點選 "Instances1 Running Instance"
  2. 選取機器, 找到 Public DNS: ec2-111-111-111-11.compute-1.amazonaws.com
  3. 按滑鼠右鍵, 選 View Details, 找到 Public DNS Name 取得 Domain name, ex: ec2-111-111-111-11.compute-1.amazonaws.com
  4. 即可直接連線: ssh [email protected] -i ~/ec2-keys/id_YOUR_NAME

強迫關機 / 重新開機

  1. 登入 Amazon EC2 Console
  2. 於 My Resources 區塊: 點選 "Instances1 Running Instance"
  3. 選取機器, 再做 "Reboot" / "Terminate" 等動作.
  4. 於機器 login 完成後, halt / shutdown -h now 等, 也可以直接關機.
  5. 不玩的時後, 記得要關機, 不然錢會一直累計喔~ 🙂

作者: Tsung

對新奇的事物都很有興趣, 喜歡簡單的東西, 過簡單的生活.

在〈Amazon EC2 簡易操作筆記 (使用 EC2 Console)〉中有 10 則留言

  1. 請問前輩,如果當初申請的Key Pairs不見了
    amazon有地方可以下載原來的Key Pairs嗎?
    或是amazon有地方可以更改ec2進入的Key Pairs Name嗎?

  2. AWS doesn't store a copy of the private key for either option.
    果真沒有辦法找到~"~
    那請問前輩,重新建立的Key Pairs可以用在舊有的機器上嗎?
    因為現在遇到的問題是要從舊的機器上把檔案全部載下來
    可是前人沒有留下Key Pairs,所以我無法進入機器裡面

    1. 進不去, 如果進得去就糟糕了... 代表安全性出了很大的漏洞阿...
      這個你可能得找看看有沒有辦法用密碼登入了.

  3. 我登录不上EC2的主机了,不知道博主有没有什么方法可以指导一下吗。
    ll ukey #这是我生成的key pairs
    -rw------- 1 eric eric 1696 Jun 4 13:43 ukey.pem
    ssh -v -i ukey.pem [email protected] #ssh登录信息如下
    OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 19: Applying options for *
    debug1: Connecting to 54.248.125.102 [54.248.125.102] port 22.
    debug1: Connection established.
    debug1: identity file ukey.pem type -1
    debug1: identity file ukey.pem-cert type -1
    debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
    debug1: match: OpenSSH_5.3 pat OpenSSH*
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: server->client aes128-ctr hmac-md5 none
    debug1: kex: client->server aes128-ctr hmac-md5 none
    debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
    debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
    debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
    debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
    debug1: Server host key: RSA 63:73:5e:94:cc:f0:6b:73:21:0a:dd:a8:e3:ed:a6:fb
    debug1: Host '54.248.125.102' is known and matches the RSA host key.
    debug1: Found key in /home/eric/.ssh/known_hosts:1
    debug1: ssh_rsa_verify: signature correct
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: SSH2_MSG_NEWKEYS received
    debug1: Roaming not allowed by server
    debug1: SSH2_MSG_SERVICE_REQUEST sent
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey
    debug1: Next authentication method: publickey
    debug1: Offering RSA public key: [email protected]
    debug1: Authentications that can continue: publickey
    debug1: Trying private key: ukey.pem
    debug1: read PEM private key done: type RSA
    debug1: Authentications that can continue: publickey
    debug1: No more authentication methods to try.
    Permission denied (publickey).

HuangMinghe 發表迴響取消回覆

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料