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?

EC2初期設定 よく使うコマンド (ec2-user パスワード追加)

Last updated at Posted at 2024-11-14

ec2-user にはパスワードが設定されていないため、設定を行います。
パスワードを二回問い合わせてくるので、適当なパスワードを設定して下さい。

$ sudo passwd ec2-user
Changing password for user ec2-user.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

ec2-user が sudo する際にパスワード入力が必要になるよう、設定を変更します。

$ sudo visudo -f /etc/sudoers.d/90-cloud-init-users

以下内容で編集

# Created by cloud-init v. 22.2.2 on Thu, 11 Jul 2024 00:38:51 +0000

# User rules for ec2-user
# ec2-user ALL=(ALL) NOPASSWD:ALL
ec2-user ALL = (ALL) ALL

sudo してみます。

$ sudo -i

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

For security reasons, the password you type will not be visible.

[sudo] password for ec2-user:

パスワード入力を求められるので、先に設定したec2-user のパスワードを入力して root ユーザになれる事を確認してください。

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?