毎回調べるのがめんどくさいので自分用に備忘としてまとめます。
謝辞
たくさんのサイトを参考にさせていただきました。
どの部分を参考にしたかわからなくなることを避けるため、項目ごとに参考にしたサイトを記載しています。
ありがとうございます☻
前提
- OS:CentOS7 1804 minimal
- ネットワーク設定が完了していること
また、今回の手順はLAN内部のサーバ構築手順なので、外部公開するサーバの場合は、より強固なセキュリティ設定(SELinux導入、firewalldでのフィルタリング)を検討してください。
SELinux無効化
# vi /etc/selinux/config
SELINUX=enforcing
↓
SELINUX=disabled
変更後、再起動します。
SSH
セキュリティ設定
# vi /etc/ssh/sshd_config
【rootログイン禁止】
#PermitRootLogin yes
↓
PermitRootLogin no
【パスワード認証禁止】
#PasswordAuthentication yes
↓
PasswordAuthentication no
ChallengeResponseAuthentication no # デフォルトだが念のため
【空のパスワードでのログイン禁止】
#PermitEmptyPasswords no
↓
PermitEmptyPasswords no
【サービス再起動】
※万が一ログインできなくなった場合に備え、既存のセッションはそのままにしておく
# systemctl restart sshd
ログインユーザ設定
wheelグループへの追加
sudoを有効にするため、 wheel グループに任意のユーザを追加します。
# usermod -G wheel user
セッション切断・再接続後、 sudo が使えます。
時刻(NTP)設定
$ sudo vi /etc/chrony.conf
【変更前】
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
【変更後】
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 172.53.12.6
server 172.53.12.5
$ sudo systemctl restart chronyd
$ sudo chronyc -a makestep # 強制的に時刻同期する
yum
(プロキシ設定)
社内でプロキシ設定が必要な場合は、以下を実施します。
$ sudo vi /etc/yum.conf
↓追加
proxy=http://proxy:8080/
リポジトリ追加
エンタープライズで信頼性の高い EPEL リポジトリを追加します。
$ sudo yum -y install epel-release
ユーティリティ追加
minimalに含まれていない各種コマンド・ユーティリティを追加します。
$ sudo yum -y install \
lsof \
vim \
bash-completion \
bind-utils \
net-tools \
psmisc \
traceroute \
tree \
wget
bashrc
crontabの恐怖のオプション -r を安全にします。
様々な方法がありますが、aliasでお手軽に設定しておきます。
$ sudo vim /etc/bashrc
↓ 最後尾に追加
alias crontab='crontab -i'
参考:"crontab" -r でいきなり削除しないようにする @LCD -Linux Command Dictionary- 【山澤】
最後の仕上げ
$ sudo yum -y update
おわりに
必要に応じて修正する可能性があります。
至らない点があればご指摘 & 編集リクエストお願いしますm(_ _)m