0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Amazon Linux 2のオンプレ実行で悩んだこと(パスワード設定)

Posted at

小ネタ。Amazon Linux 2 限定でなくcloud-initの話でした。

Amazon Linux 2 のオンプレミスでの実行

公式

Qiitaならこれ(VMware ESXi画面キャプチャつき)

cloud-initでのパスワード設定

user-dataファイルにcloud-initとして設定する。AWSのドキュメントのサンプルには下記があるが、

# cloud-config
# vim:syntax=yaml
users:
# A user by the name `ec2-user` is created in the image by default.
  - default
chpasswd:
  list: |
    ec2-user:plain_text_password
# In the above line, do not add any spaces after 'ec2-user:'.

コメント除いたQiita記事を見たのと、公式ドキュメントをちゃんと見なかったので、はいはい、ec2-userがkeyでパスワードをYAMLのvalueにするのだな、と勘違いし、ec2-userとパスワードの間にスペースを入れてしまった。

-    ec2-user: plain_text_password
+    ec2-user:plain_text_password

OSはちゃんと起動しているし、ホスト名は設定されているし、IPアドレスも設定されている。しばらくにらめっこし、これはchpasswdコマンドへの引数でありec2-user:plain_text_password:がデリミタで繋いでいるものということに気がつく。っていうかそれちゃんとサンプルのコメントに書いてあるし。

とりあえずseed.isoで設定済みのパスワードの先頭にスペースを追加してログインはできた。

まとめ

In the above line, do not add any spaces after 'ec2-user:'.って書いてある通り。なのでスペースを挟んじゃいけないし、この理由はchpasswdでパスワードを設定しているから。これは、他のcloud-initでchpasswdによりパスワード初期化するOSも同じ。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?