CentOS 7.3 インストール

Server Worldさんを参考にして最少インストールしました。

言語の選択
 → English
タイムゾーン
 → Asia/Tokyo
キーボード
 → Japanese 優先順位を一番に
SOFTWARE SELECTION
 → Minimal Install
インストール先のディスク
 → HDD
NETWORK & HOSTNAME
 Hostname → ホスト名
 Ethernet → ON
Begin Installation
 インストールが始まります → rootパスワード設定とユーザー作成
インストール完了
 → Reboot
再起動後
 → login: プロンプトが表示される。

ファイアウォール

ルールの削除
firewall-cmd --list-all-zone
firewall-cmd --permanent --zone=public --remove-service=dhcpv6-client
firewall-cmd --permanent --zone=public --remove-service=ssh
firewall-cmd --permanent --zone=home --remove-service=dhcpv6-client
firewall-cmd --permanent --zone=home --remove-service=mdns
firewall-cmd --permanent --zone=home --remove-service=samba-client
firewall-cmd --permanent --zone=home --remove-service=ssh
firewall-cmd --permanent --zone=internal --remove-service=mdns
firewall-cmd --permanent --zone=internal --remove-service=dhcpv6-client
firewall-cmd --permanent --zone=internal --remove-service=samba-client
firewall-cmd --permanent --zone=internal --remove-service=ssh
firewall-cmd --permanent --zone=work --remove-service=ssh
firewall-cmd --permanent --zone=work --remove-service=dhcpv6-client
firewall-cmd --permanent --zone=external --remove-service=ssh
firewall-cmd --permanent --zone=dmz --remove-service=ssh
ルールの追加
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=dns
firewall-cmd --permanent --zone=public --add-service=smtp
firewall-cmd --permanent --zone=public --add-service=pop3
firewall-cmd --permanent --zone=public --add-service=ftp
firewall-cmd --permanent --zone=trusted --add-source=xxx.xxx.xxx.xxx/24
firewall-cmd --permanent --zone=trusted --add-service=ssh
ルールの反映
firewall-cmd --reload
firewall-cmd --list-all-zone

SELinux (Security-Enhanced Linux)

permissive モードに変更
# vi /etc/selinux/config
SELINUX=enforcing  → SELINUX=permissive

ネットワーク設定

ホスト名設定
# hostnamectl set-hostname srv.hogehoge.com
デバイス確認
# nmcli d
DEVICE TYPE STATE CONNECTION
ens192 ethernet connected ens192
lo loopback unmanaged --
固定IPv4アドレス設定
# nmcli c modify ens192 ipv4.addresses 10.1.1.1/24
デフォルトゲートウェイ設定
# nmcli c modify ens192 ipv4.gateway 10.1.1.254
参照する DNS設定
# nmcli c modify ens192 ipv4.dns 10.0.1.1 10.1.1.1
IP固定割り当てに設定
# nmcli c modify ens192 ipv4.method manual
インターフェースを再起動
# nmcli c down ens192; nmcli c up ens192

IPv6設定

必要ないので、IPv6 を無効にします。
# vi /etc/default/grub
GRUB_CMDLINE_LINUX="crashkernel=auto、、、
 → GRUB_CMDLINE_LINUX="ipv6.disable=1 crashkernel=auto、、、
# grub2-mkconfig -o /boot/grub2/grub.cfg
# reboot

リモート管理

sshでrootログイン禁止と鍵認証方式にします。
# vi /etc/ssh/sshd_config
主な変更箇所
LoginGraceTime 2m
PermitRootLogin no
StrictModes yes
MaxAuthTries 3
MaxSessions 5
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
ChallengeResponseAuthentication no
UseDNS no
鍵を作成し、鍵認証でログインできるようにします。
$ ssh-keygen -t rsa
$ mv ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys
Windows クライアントからの SSH 鍵認証
$ .ssh/id_rsaをSCPでダウンロードします。
Puttygen.exeを起動し鍵を取り込みます。
ppk形式でプライベートキーを保存します。
Putty側の接続設定で接続→SSH→認証
認証のためのプライベートキーファイルに先ほど保存したppk形式のファイルを指定します。

システム最新化

最新パッケージに更新します。
# yum -y update
# reboot

リポジトリの追加設定

リポジトリに優先順位が付けられるプラグインを入れます。
# yum -y install yum-plugin-priorities
# sed -i -e "s/\]$/\]\npriority=1/g" /etc/yum.repos.d/CentOS-Base.repo
スペシャルパッケージを配布する EPEL を追加
# yum -y install epel-release
# sed -i -e "s/\]$/\]\npriority=5/g" /etc/yum.repos.d/epel.repo

sudo設定

root権限を特定のグループに限定する
# visudo
Cmnd_Alias SHUTDOWN = /sbin/halt, /sbin/shutdown, /sbin/poweroff, /sbin/reboot, /sbin/init

%wheel ALL=(ALL) ALL, !SHUTDOWN
suコマンドの一般ユーザ禁止
# ls -l /usr/bin/su
-rwsr-xr-x 1 root root 32088 11月 6 07:27 /usr/bin/su
# chmod 4700 /usr/bin/su
# ls -l /usr/bin/su
-rws------. 1 root root 32088 Nov 6 07:27 /usr/bin/su

cron変更

anacron → noanacron
# yum -y install cronie-noanacron
# yum -y remove cronie-anacron

↑先頭