INDEX
OpenBSD ユーザ・グループ関係 (7.1 ARMv7 on BBB 版)
OpenBSD のユーザ・グループ関係。対象は、OpenBSD 7.1 ARMv7 on BBB。
rootユーザ
メール転送
cron などから送られる root 宛のメールを POP3 で受信できるように管理者用のアカウントに転送する。インストール時にユーザを作成している場合、そのユーザに転送するように設定される。
メールの転送は、~/.forward で設定する。
bbb# cat ~/.forward admin
リモートログイン
メンテナンス用に ssh と sftp が使えるように、公開鍵を設定する。シェルは su や sudo doas を利用できるけど、ファイル転送で root しか権限がないファイルを触る場合は、一般ユーザを経由して転送する必要がある。
公開鍵は、~/.ssh/authorized_keys に記載する。
bbb# cat ~/.ssh/authorized_keys ssh-rsa AA(中略)AA== admin public key
doas - 別ユーザーとしてコマンド実行
OpenBSD 5.8 からは、sudo から doas(1) コマンドに変わっている。
doas を利用するには、/etc/doas.conf ファイルを作成し、利用可能なユーザ・コマンドを設定しておく必要がある。サンプルが /etc/examples/doas.conf にあり、「permit keepenv :wheel」と wheel グループに許可されている。
- 関連 man → doas(1), doas.conf(5)
設定
サンプルをベースに persist を追加して、しばらくの間パスワードを求めないようにしておく。
bbb# cp -p /etc/examples/doas.conf /etc/doas.conf bbb# vi /etc/doas.conf bbb# doas -C /etc/doas.conf bbb# cat /etc/doas.conf # $OpenBSD: doas.conf,v 1.1 2016/09/03 11:58:32 pirofti Exp $ # Configuration sample file for doas(1). # See doas.conf(5) for syntax and examples. # Allow wheel by default permit persist keepenv :wheel bbb#
設定の確認
設定ファイルのチェックは、-C ファイル名 でチェックできる(エラーがあればその行数が、正常なら何も表示されない)。
また、コマンドと引数まで指定すると許可されるか‘permit’,‘permit nopass’ or ‘deny’が標準出力に出力される。
bbb# doas -C /etc/doas.conf bbb# doas -C /etc/doas.conf id permit bbb#
ユーザとグループを追加
スケルトン
ユーザーアカウントを新規に作成した際に /etc/skel/ ディレクトリに用意されている内容を作成したユーザのホームディレクトリにコピーされる。
bbb# ls -lF /etc/skel/ total 28 -rw-r--r-- 1 root wheel 87 Apr 15 05:16 .Xdefaults -rw-r--r-- 1 root wheel 769 Apr 15 05:16 .cshrc -rw-r--r-- 1 root wheel 101 Apr 15 05:16 .cvsrc -rw-r--r-- 1 root wheel 359 Apr 15 05:16 .login -rw-r--r-- 1 root wheel 175 Apr 15 05:16 .mailrc -rw-r--r-- 1 root wheel 212 Apr 15 05:16 .profile drwx------ 2 root wheel 512 Apr 15 07:34 .ssh/ bbb# ls -lF /etc/skel/.ssh/ total 0 -rw------- 1 root wheel 0 Apr 15 05:16 authorized_keys bbb#
例えば、Webサーバでユーザディレクトリを使っている場合、"public_html" ディレクトリを作成し、ダミーの index.html を入れておく。
例えば、SSHサーバでユーザにログオンをさせる場合、".ssh" ディレクトリを作成し、空の "authorized_keys" ファイルを作成しておく(4.3 以降からは既に作成されている)。
など…
グループを追加
ユーザの所属するグループを追加する。
bbb# groupadd グループ名
ユーザを追加
一般ユーザを追加する。
adduser コマンドを利用する。初めての(/etc/adduser.conf がない)場合デフォルトの設定が行われる。
また、useradd コマンドもあるが、対話式では行われず、スケルトンのコピーなどもされない(別途ホームディレクトリの作成が必要)。
bbb# adduser Couldn't find /etc/adduser.conf: creating a new adduser configuration file Reading /etc/shells Enter your default shell: csh ksh nologin sh [ksh]: Your default shell is: ksh -> /bin/ksh Default login class: authpf bgpd daemon default pbuild staff unbound [default]: Enter your default HOME partition: [/home]: Copy dotfiles from: /etc/skel no [/etc/skel]: Send welcome message?: /path/file default no [no]: Do not send message(s) Prompt for passwords by default (y/n) [y]: Default encryption method for passwords: auto blowfish [auto]: Use option ``-silent'' if you don't want to see all warnings and questions. Reading /etc/shells Check /etc/master.passwd Check /etc/group Ok, let's go. Don't worry about mistakes. There will be a chance later to correct any input.
Enter username []: sftpuser Enter full name []: Enter shell csh ksh nologin sh [ksh]: Uid [1001]: Login group sftpuser [sftpuser]: general Login group is ``general''. Invite sftpuser into other groups: guest no [no]: sftponly Login class authpf bgpd daemon default pbuild staff unbound [default]: Enter password []: Enter password again []: Name: sftpuser Password: **** Fullname: sftpuser Uid: 1001 Gid: 1000 (general) Groups: general sftponly Login Class: default HOME: /home/sftpuser Shell: /bin/ksh OK? (y/n) [y]: y Added user ``sftpuser'' Copy files from /etc/skel to /home/sftpuser Add another user? (y/n) [y]: n Goodbye!
最終更新時間:2022年05月29日 17時53分26秒 指摘や意見などあればSandBoxのBBSへ。