3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OCI Computeインスタンスのログインユーザーを変更する

Posted at

はじめに

OCIのComputeインスタンスのデフォルトユーザーはopcですが、複数人でopcユーザーを使ってると、監査の都合上よくない場合があります。(誰が操作したかわからないので)
そこで、各自のユーザーを作成して、opcにsuするようにした際の手順です。

ユーザーを作成し、SSHでログインできるようにする

こちらの内容を参考に各自のユーザーを作成し、SSH接続できるようにします。

パスワードなしでopcにsuできるようにする

PAM認証モジュールの設定ファイル/etc/pam.d/suの以下の記載の下に2行追記します。

auth sufficient pam_rootok.so

/etc/pam.d/su
・・・
auth            sufficient      pam_rootok.so

auth       [success=ignore default=1] pam_succeed_if.so user = opc #追記
auth       sufficient   pam_succeed_if.so use_uid user ingroup opc #追記
・・・

opcグループに作成したユーザーを追加します。

$ sudo usermod -aG opc ユーザー名

SSHの設定変更

/etc/ssh/sshd_configファイルにAllowUsersの行を追加して、作成したユーザーを記載します。複数いる場合はスペースで区切ります。ついでにrootでSSH接続できないようにしておきます。

PermitRootLogin no #yesをnoに変更

AllowUsers ユーザー名1 ユーザー名2 #追記

sshdを再起動します。

sudo systemctl reload sshd
sudo systemctl restart sshd
3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?