Ubuntu18.04インスタンスにCloud9 を導入する(備忘録

基本的な手順は下記参照。

qiita.com

 

PuTTYで接続する際のSSHキーの作成方法。

docs.aws.amazon.com

 

  1. AWSで「新しいキーペアを作成」を選ぶ。
  2. pemファイルがダウンロードされる。
  3. pemファイルのままだとPuTTYで使えないので
  4. PuTTYgenでppkファイルに変換する。
  5. 変換したファイルを使ってSSH接続

 

 

PuTTYでpem > pkk 変換の流れ

To convert your private key

  1. Start PuTTYgen (for example, from the Start menu, choose All Programs > PuTTY > PuTTYgen).

  2. Under Type of key to generate, choose RSA.

    
							RSA key in PuTTYgen

    If you're using an older version of PuTTYgen, choose SSH-2 RSA.

  3. Choose Load. By default, PuTTYgen displays only files with the extension .ppk. To locate your .pem file, select the option to display files of all types.

    
							Select all file types
  4. Select your .pem file for the key pair that you specified when you launched your instance, and then choose Open. Choose OK to dismiss the confirmation dialog box.

  5. Choose Save private key to save the key in the format that PuTTY can use. PuTTYgen displays a warning about saving the key without a passphrase. Choose Yes.

    Note

    A passphrase on a private key is an extra layer of protection, so even if your private key is discovered, it can't be used without the passphrase. The downside to using a passphrase is that it makes automation harder because human intervention is needed to log on to an instance, or copy files to an instance.

  6. Specify the same name for the key that you used for the key pair (for example, my-key-pair). PuTTY automatically adds the .ppk file extension.

Your private key is now in the correct format for use with PuTTY. You can now connect to your instance using PuTTY's SSH client.

 

 

PuTTYAWSに接続する流れ

  • PuTTYを開く
  • ConnectionからSSHを開いて、Authを選ぶ。
  • Authの中にBrowseというボタンがあるので先程作ったキー(.ppk)を選ぶ。

 

In the Category pane, expand Connection, expand SSH, and then choose Auth. Complete the following:

  1. Choose Browse.

  2. Select the .ppk file that you generated for your key pair, and then choose Open.

  3. (Optional) If you plan to start this session again later, you can save the session information for future use. Choose Session in the Category tree, enter a name for the session in Saved Sessions, and then choose Save.

  4. Choose Open to start the PuTTY session.

 

 

PuTTYのSessionの設定

ホスト名:パブリックDNS

※サービス > EC2 > インスタンスで調べる

 

ユーザー名:

今回はUbuntuのAMI(Amazon マシンイメージ)を使ったので"ubuntu"

 

 

Host Nameに

user_name@public_dns_name

という書き方で書くといちいちユーザ名の認証がなくて楽。

 

In the Host Name box, enter user_name@public_dns_name. Be sure to specify the appropriate user name for your AMI. For example:

  • For Amazon Linux 2 or the Amazon Linux AMI, the user name is ec2-user.

  • For a Centos AMI, the user name is centos.

  • For a Debian AMI, the user name is admin or root.

  • For a Fedora AMI, the user name is ec2-user or fedora.

  • For a RHEL AMI, the user name is ec2-user or root.

  • For a SUSE AMI, the user name is ec2-user or root.

  • For an Ubuntu AMI, the user name is ubuntu.

  • Otherwise, if ec2-user and root don't work, check with the AMI provider.

 

ここまででとりあえずログインできた。

 

 

 

一番上に示したQiitaの手順に従って、

sudo apt update
sudo apt upgrade
sudo apt install -y nodejs

 

 

自分の場合、nodejsの他に、

Python2.7が入ってないというエラーが出たのでPython2.7を導入。

(Python2.7が入ってないパターン初めて見た。Python3は入っていた。)

 

>|sh|

$ sudo apt install python

 

$ python --version
Python 2.7.15rc1

||<

 

そしたら、

Cloud9で

Create Environment > Connect and run in remote server (SSH)

を選択してpublic SSH keyをコピーする。

 

 

SSH keyをコピーしたらPuTTY側で、

~/.ssh/authorized_keysにCloud9用のキーを追記。

 

>|sh|

echo [public SSH key貼り付け]  >> ~/.ssh/authorized_keys

||<

 

 

もともと記述されていたAWSSSHキーと

Cloud9のSSHキーの両方があることを確認する

>|sh|

cat ~/.ssh/authorized_keys

||<

 

問題なければ、

あとはCloud9を適当に進めてインストールは完了。