2
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 5 years have passed since last update.

Amazon Linuxで(普通の)ユーザーを追加する

2
Last updated at Posted at 2019-07-25

TL;DR

# local

# Generate an SSH key pair.
ssh-keygen -t rsa -b 4096 -C "your_name@your.domain" -f /path/to/new_key_pair.pem

# remote

# Add a new user.
sudo adduser new_user
sudo su - new_user  # Log in as the new user.

# remote (new_user)

mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
cat >> .ssh/authorized_keys
# Here, paste "/path/to/your_key_pair.pem.pub", Enter (for a new line), Ctrl+D (to exit cat)
exit

# local

ssh -i /path/to/new_key_pair.pem new_user@public_dns_name_of_EC2_Linux_instance

.pem.pubがないとき?

# 秘密鍵から公開鍵を表示する。
ssh-keygen -y -f /path/to/new_key_pair.pem

アカウント期限を設定

# アカウント作成時に期限を設定する。
sudo adduser -e 2020-09-30 new_user

# 後からアカウント期限を変更する。
sudo chage -E 2020-12-31 new_user

# 確認する。
sudo chage -l new_user

参考

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