LoginSignup
0
0

More than 5 years have passed since last update.

Linux ユーザ追加周りメモ

Last updated at Posted at 2018-12-24

ユーザ追加周りのコマンド忘れがちなのでメモ。

ユーザの追加と確認

$ sudo adduser <username>
$ cat /etc/passwd | grep home
ec2-user:x:500:500::/home/ec2-user:/bin/bash
<username>:x:501:501::/home/<username>:/bin/bash

ユーザのパスワード変更とsudo権限付与

$ sudo passwd <username>
ユーザー <username> のパスワードを変更。
新しいパスワード:
新しいパスワードを再入力してください:
passwd: 全ての認証トークンが正しく更新できました。
$ sudo visudo
<username>        ALL=(ALL)       ALL // この行を追加

SSHログインの設定

$ sudo su - <username> // ユーザ切り替え
 $ mkdir .ssh // .sshディレクトリ作成
 $ ls -al
 $ chmod 700 .ssh/
 $ cd .ssh/
 $ touch .ssh/authorized_keys
 $ chmod 600 .ssh/authorized_keys // 後は公開鍵の中身をログインしたい方から貰って貼り付ければOK

ユーザの削除

$ sudo userdel -r <username>
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