PR

CentOS インストール後にやっておくこと

SELINUXの無効化やperlシンボリックの作成等

/etc/rc.d/init.d/iptables stop
chkconfig iptables off
/etc/rc.d/init.d/ip6tables stop
chkconfig ip6tables off

setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux

ln -s /usr/bin/perl /usr/local/bin/perl
reboot

スポンサードリンク

アップデート

yum -y update
reboot

NTP設定

yum -y install ntp
ntpdate ntp.dnsbalance.ring.gr.jp
vi ntpdate

#!/bin/bash
/usr/sbin/ntpdate ntp.dnsbalance.ring.gr.jp > /dev/null

chmod +x ntpdate
mv ntpdate /etc/cron.daily/

ネットワーク設定(ホスト名ほか)

hostnameの設定

vi /etc/sysconfig/network
HOSTNAME=host.example.jp

適用するには /etc/rc.d/init.d/network restart または reboot

hosts の設定

vi /etc/hosts

127.0.0.1              host.example.jp  localhost.localdomain localhost

ネットワーク設定(IP アドレス固定ほか)

vi /etc/sysconfig/network で GATEWAY を追記

NIC の設定

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
BROADCAST=192.168.1.255
IPADDR=192.168.1.123
NETMASK=255.255.255.0
NETWORK=192.168.1.0

ネームサーバの設定

# vi /etc/resolv.conf
nameserver 192.168.1.1

ロケールをja_JP.utf-8に変更

vi /etc/sysconfig/i18n
LANG=ja_JP.eucJP

LANG="ja_JP.utf-8"

root宛メールを外部メールアドレスで受信する

vi /etc/aliases

#  Aliases in this file will NOT be expanded in the header from
#  Mail, but WILL be visible over networks or from /bin/mail.
#
# Basic system aliases -- these MUST be present.
mailer-daemon:  postmaster
postmaster:     root

# General redirections for pseudo accounts.
bin:            root
daemon:         root
adm:            root
lp:             root

root:           [email protected]

適用

newaliases

容量警告

→ pc.casey.jp » [Linux] ディスクの容量不足を警告するスクリプト~設置編~

不要サービスの停止(例)

確認

# chkconfig --list | sort | grep 3:on

停止

デバイス・インターフェイス

chkconfig bluetooth off
chkconfig cups off
chkconfig pcscd off
chkconfig hidd off
chkconfig irda off
chkconfig acpid off
chkconfig apmd off
chkconfig microcode_ctl off

SELinux

chkconfig auditd off
chkconfig mcstrans off
chkconfig restorecond off

ほか

chkconfig firstboot off
chkconfig atd off
chkconfig autofs off
chkconfig avahi-daemon off
chkconfig mdmonitor off
chkconfig yum-updatesd off

SSH接続制限とセキュリティー

鍵交換方式を使う

ログイン通知を設定する

SSHでログインしたときSSHDは以下があれば実行する。

$HOME/.ssh/rc

SSH で遠隔ログインした時にメールで通知する – いますぐ実践! Linuxシステム管理 / Vol.010を参考にログインしたときにメール通知を行うように設定できる。

ログイン可能な端末を制限する

IPアドレスで制限する例

# vi /etc/hosts.allow
sshd:xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx
# vi /etc/hosts.deny
sshd: ALL

rootログインの禁止

# vi /etc/ssh/sshd_config
PermitRootLogin yes

PermitRootLogin no

sshdを再起動

# service sshd restart

参考文献

oldId.2009070106225536

コメント