環境設定
【1.ユーザー環境の設定】
# groupadd ando
# useradd -g ando -p 0000 ando
パスワード設定
# passwd ando
Changing password for user ando
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
作業ディレクトリの作成
# cd /home/ando/
# mkdir tmp work src
# chown ando:ando *
【2.不要な起動プロセスの排除】
セキュリティの観点から、余分なプロセスはなるべく停止しよう。
[不要なプロセス停止]
# cd /home/ando/work/
# vi chkconfig.sh
#!/bin/sh/sbin/chkconfig acpid off
/sbin/chkconfig apmd off
/sbin/chkconfig atd off
/sbin/chkconfig autofs off
/sbin/chkconfig bluetooth off
/sbin/chkconfig cups off
/sbin/chkconfig gpm off
/sbin/chkconfig ip6tables off
/sbin/chkconfig netfs off
/sbin/chkconfig nfslock off
/sbin/chkconfig portmap off
/sbin/chkconfig sendmail off
/sbin/chkconfig smartd off
/sbin/chkconfig xfs off
/sbin/chkconfig yum-updatesd off
/sbin/chkconfig vncserver off
# chmod 755 chkconfig.sh
# ./chkconfig.sh
[不要なプロセス確認]
# vi check.sh
#!/bin/shlog=/home/ando/work/chkconfig.log
chkconfig --list | grep "acpid" >> $log
chkconfig --list | grep "apmd" >> $log
chkconfig --list | grep "atd" >> $log
chkconfig --list | grep "autofs" >> $log
chkconfig --list | grep "cups" >> $log
chkconfig --list | grep "gpm" >> $log
chkconfig --list | grep "ip6tables" >> $log
chkconfig --list | grep "netfs" >> $log
chkconfig --list | grep "nfslock" >> $log
chkconfig --list | grep "portmap" >> $log
chkconfig --list | grep "sendmail" >> $log
chkconfig --list | grep "smartd" >> $log
chkconfig --list | grep "xfs" >> $log
chkconfig --list | grep "yum-updatesd" >> $log
chkconfig --list | grep "vncserver" >> $log
# chmod 755 check.sh
# ./check.sh
# cat chkconfig.log
[不要なプロセス削除]
ディレクトリ,/etc/rc3.dと/etc/rc6.dの中にあるプログラムの起動ファイルを削除します.
■/etc/rc3.d では次のファイルを削除します.
# cd /etc/rc3.d
# rm -f S13portmap S14nfslock S25netfs S26apmd S28autofs S26acpid S56cups S56rawdevices S80sendmail S90xfs S95atd S08iptables S85gpm K24irda S25bluetooth
■/etc/rc6.d では次のファイルを削除します.
# cd /etc/rc6.d
# rm -f K10xfs K10cups K15gpm K24irda K30sendmail K74acpid K74apmd K75netfs K90bluetooth
【3.SSHの設定】
【rootでのリモート接続禁止】
■セキュリティ上リモートから直接rootで接続するのは好ましくないため,SSHに対してroot接続を禁止します.(リモート接続でroot権限を使用する際は一度作成したユーザーでログオンし,su -とすることでrootになります.)
# vi /etc/ssh/sshd_config
# Authentication:
#LoginGraceTime 2m
PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
■ファイル内の認証に関する項目で,#PermitRootLogin yesという部分を見つけ,PermitRootLogin noとすることでリモートから直接rootで入ることができなくなります.
■編集がおわったらZZとして保存・終了します.
【4.文字コードの設定】
文字コードの設定はお好みで、お願い致します。
# vi /etc/sysconfig/i18n
LANG="ja_JP.eucJP"
SUPPORTED="ja_JP.eucJP:ja_JP:ja"
SYSFONT="latarcyrheb-sun16"
【5. bashrcなどお好み変更】
# vi /etc/bashrc
ここにふざけて、lsコマンドを打つとslコマンドに変更して、汽車が動いたら、みんなビックリするよwww。早い人だとすぐにbashrcを書きかえたのばれるけど。
# System wide functions and aliases
# Environment stuff goes in /etc/profile#2010/07/02 K.Ando
#common environment variables
export htla='/usr/local/apache2/logs/access_log'
export htle='/usr/local/apache2/logs/error_log'
export htd='/usr/local/apache2/htdocs/'
export SVN_EDITOR='vi'#common aliases
alias psql='/usr/local/pgsql/bin/psql -U postgres'
alias htla='tail -f ${htla}'
alias htle='tail -f ${htle}'
alias htd='cd ${htd}'
alias cd..='cd ..'
alias vi='vim'
# source /etc/bashrc
【6.ネットワーク設定】
[IPアドレスの設定]
■あらかじめ決められているIPアドレス,ホスト名,ケートウェイ,DNSサーバアドレスを設定します.
■ネットワーク設定はサーバに搭載されているネットワークボードごとに設定をするため,それぞれに設定を行う.(大抵は2枚〜3枚)
■IPADDR,NETMASKは構築するサーバごとに異なるのでその都度確認する.
■viエディタで開いた後,aを押して編集モードになり,記述の編集をする.
■編集が完了したらEscキーを押してコマンドモードになり,Zキーを2回押して終了する(大文字のZ).
[ネットワークボード1枚目の設定]
# cd /etc/sysconfig/network-scripts
# vi ifcfg-eth0
# Broadcom Corporation NetXtreme II BCM5716 Gigabit Ethernet
DEVICE=eth0
BOOTPROTO=static
HWADDR=**:**:**:**:**:**
ONBOOT=yes
IPADDR=192.168.***.***
NETMASK=255.255.255.0
[ネットワークボード2枚目の設定]
# cd /etc/sysconfig/network-scripts
# vi ifcfg-eth1
# Broadcom Corporation NetXtreme II BCM5716 Gigabit Ethernet
DEVICE=eth0
BOOTPROTO=static
HWADDR=**:**:**:**:**:**
ONBOOT=yes
IPADDR=192.168.***.***
NETMASK=255.255.255.0
三枚目も、自分の環境に合わせてお願い致します。
[ゲートウェイ,ホストの設定]
■ゲートウェイとホスト名は/etc/sysconfig/network に対して記述する.
■ゲートウェイ,ホスト名はサーバを構築する都度異なるので確認する.
# cd /etc/sysconfig/
# vi network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=SV-Ando
GATEWAY=192.168.***.***
[DNSの設定]
■外部ネットワークホスト名解決のためDNSサーバを指定します.
■構築するサーバによっては指定するアドレスが変わるので設定書を確認する.
■場合によってはOSインストール時に設定されるので変更しなくてもよい.また,2つのアドレスが設定されているのは,上がプライマリ,下がセカンダリのDNSサーバである.1つしかない場合は1つ記述.
# vi /etc/resolv.conf
nameserver ***.***.***.***
nameserver ***.***.***.***
[動作確認]
■設定が完了したらshutdown -r nowとして再起動させますまたは、/etc/init.d/network restartでネットワークが環境に合わせて動いているか確認する。