LoginSignup
2
1

More than 5 years have passed since last update.

管理者ユーザーの作成

Posted at

概要

AWS EC2等でインスタンスを立ち上げた際に、ec2-userで立ち上がるがセキュリティ面より別の管理者ユーザーを作成することをお勧めします。

手順

ユーザー作成

$ useradd -m <ユーザ名>

# 確認する
$ ls -l /home/

パスワード設定

$ passwd <ユーザ名>

権限の付与

$ visudo

# 以下を追記する
<ユーザ名> ALL=(ALL) ALL

# 確認する
$ view /etc/sudoers

ssh-keyをコピーする

$ cp -arp /home/ec2-user/.ssh /home/<ユーザ名>/
$ sudo chown -R <ユーザ名> /home/<ユーザ名>/.ssh

その他

ec2-userの権限を剥奪する場合は以下のファイルを編集する

$ visudo -f /etc/sudoers.d/cloud-init

参考

以下の記事を参考にさせていただきました。
ありがとうございます。
https://eng-entrance.com/linux-user-add
https://saku.io/first-step-on-ec2/

2
1
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
2
1