AWSにUbuntuをセットアップし、FabricをDockerで起動してみたいと思います。
普段はVirtualBox内のUbuntuでFabricを動かしていて、AWSを触るのは初めて。
果たして最後までできるのかわかりませんが、とりあえず始めてみます。
今回はAWSでサーバを準備する手順をメモ。
大きく分けると以下の手順を実行します。
- EC2インスタンス作成〜起動
- SSH設定変更
- ターミナルからインスタンスへ接続する
1. EC2インスタンス作成〜起動
Ubuntu Server 16.04 LTSを選択して続行します
インスタンスタイプは無料枠のtc2.microのまま、続行します
キーペアに適当な名前を入力してファイルをダウンロードします
ダウンロードしたファイルは、~/.ssh ディレクトリに保管しましょう
作成には数分かかります
さきにEC2コンソールへ移動しましょう
ここでSSHログイン試行するも、タイムアウトで接続できず。
軽く調べたところ、SSHの設定の変更が必要?とのこと。
次の手順でセキュリティグループの設定を変更します。
2. SSH設定変更
インスタンスを選択すると詳細が下の方に表示されます
この中から、セキュリティグループを選択します
SSHのインバウンドのソースが特定のネットワークに限定されているため解除します
編集を選択します
3. ターミナルからインスタンスへ接続する
インスタンス作成時に保存したキーペアファイルが~/.sshディレクトリにコピーされている前提です。
権限を編集してからsshで繋ぎます。
AWSのUbuntuでは、ubuntuがデフォルトユーザになります。
アクセス先のIPアドレスは、インスタンスの「パブリックDNS(IPv4)」です。
$ chmod 400 .ssh/user1.pem
$ ssh -i ".ssh/user1.pem" ubuntu@ec2-xx-xx-xx-xx.us-east-2.compute.amazonaws.com
The authenticity of host 'ec2-xx-xx-xx-xx.us-east-2.compute.amazonaws.com (xx-xx-xx-xx)' can't be established.
ECDSA key fingerprint is SHA256:xxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ec2-xx-xx-xx-xx.us-east-2.compute.amazonaws.com,xx-xx-xx-xx' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-1043-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
0 packages can be updated.
0 updates are security updates.
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
ubuntu@ip-xx-xx-xx-xx:~$ pwd
/home/ubuntu
AWS EC2のUbuntu 16.04に、SSHでログインできました。
次は、Fabricを起動できればと思います。