CentOS6.7の設定
前回インストールしたCentOS6.7の設定を行っていきます。
SELinuxの無効化
何はともかく無効化しましょう。以下に設定変更します。
SELINUX=disabled
# [cp -a /etc/sysconfig/selinux{,.bak}
# vi /etc/sysconfig/selinux
# shutdown -r now
SELinuxが無効化された事を確認します
# getenforce
Disabled
開発ツール、Baseパッケージのインストール
# yum groupinstall base
# yum groupinstall development tools
監視ユーザ追加
# useradd hogehoge
# passwd hogehoge
ユーザー hogehoge のパスワードを変更。
新しいパスワード:
新しいパスワードを再入力してください:
passwd: 全ての認証トークンが正しく更新できました。
作成したユーザに管理者権限付与
/etc/sudoersに以下の内容を記載
hogehoge ALL=(ALL) ALL
# cp -a /etc/sudoers{,.bak}
# visudo
# cat /etc/sudoers |grep hogehoge
hogehoge ALL=(ALL) ALL
$ sudo whoami
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for hogehoge:
root
root権限が付与された事を確認。
rootユーザリモートログイン不可設定
rootでssh接続は禁止して、作成したユーザでssh接続するようにしましょう。
PermitRootLogin no
# cp -a /etc/ssh/sshd_config{,.bak}
# vi /etc/ssh/sshd_config
# service sshd restart
# service sshd restart
sshd を停止中: [ OK ]
sshd を起動中: [ OK ]
# cat /etc/ssh/sshd_config | grep PermitRootLogin
#PermitRootLogin yes
PermitRootLogin no
PermitRootLogin noが追加されていることを確認。サービスも正常に起動しています。
リモートログインの確認
rootユーザでのログイン不可の確認します。
# ssh [email protected]
The authenticity of host 'xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'xxx.xxx.xxx.xxx' (RSA) to the list of known hosts.
[email protected]'s password:
Permission denied, please try again.
Permission deniedで権限が拒否された事を確認
一般ユーザでのログイン確認
# ssh [email protected]
[email protected]'s password
$
一般ユーザが管理者権限になることを確認
$ sudo su -
[sudo] password for hogehoge:
#
プロンプトが管理者権限になったので管理者権限になることに成功
プロンプトが一般ユーザになったのでログイン成功
Quizここで#や$になったりしているのはなぜでしょうか。調べてコメント欄に書いてみてください。
カーネルパニック設定
「/etc/sysctl.conf」はカーネルパラメータを記述する設定ファイルです。 ここにパニックリブートの設定を追加
# cp -a /etc/sysctl.conf{,.bak}
# echo >> /etc/sysctl.conf
# echo kernel.panic = 30 >> /etc/sysctl.conf
# cat /etc/sysctl.conf |grep kernel.panic
kernel.panic = 30 //パニック後30秒後に再起動
yum設定
参考サイト : Yumの構成 : yumが遅い場合にダウンロードを速くするyum-fastestmirror : CentOSでyumのリポジトリを国内指定したりほか
1.yumのプラグインをインストールしてダウンロードの速いミラーサイトを自動で選択するように設定
yum -y install yum-fastestmirror
2.「mirrorlist=」の末尾に「&cc=JP」を追記し、国コード別のミラーリストを返すように設定
# cp -a /etc/yum.repos.d/CentOS-Base.repo{,.bak}
# vi /etc/yum.repos.d/CentOS-Base.repo
# cat /etc/yum.repos.d/CentOS-Base.repo |grep mirrorlist=
# If the mirrorlist= does not work for you, as a fall back you can try the
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra&cc=JP
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra&cc=JP
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra&cc=JP
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra&cc=JP
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra&cc=JP
3.「yum -y update」ですべてのパッケージを、それらが依存するパッケージとともに更新
# yum -y update
4.更新がないことを確認
# yum check-update
読み込んだプラグイン:fastestmirror, security
Loading mirror speeds from cached hostfile
* base: ftp.tsukuba.wide.ad.jp
* extras: ftp.tsukuba.wide.ad.jp
* updates: ftp.tsukuba.wide.ad.jp
5.yumおよび関連ユーティリティの設定ファイルである「/etc/yum.conf」でpluginsが1に設定されていて、yumの機能を拡張するプラグインが有効である事を確認
# cat /etc/yum.conf |grep plugins=1
plugins=1
6.mirrorlistの設定が正しくされているか確認
# cat /etc/yum.repos.d/CentOS-Base.repo | grep mirrorlist=http://
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra&cc=JP
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra&cc=JP
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra&cc=JP
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra&cc=JP
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra&cc=JP
自動起動設定
1.以下のサービスを自動起しない用設定
# chkconfig --level 2345 mdmonitor off
# chkconfig --level 2345 atd off
# chkconfig --level 2345 smartd off
# chkconfig --level 2345 haldaemon off
# chkconfig --level 2345 restorecond off
| サービス名 | サービス内容 |
|---|---|
| mdmonitor | ソフトウェアRAIDをモニターするサービスなのでソフトウェアRAIDを使用していないので無効 |
| atd | 単発的にスケジュール化した コマンド を実行させるデーモン。指定時間にコマンド実行を行える,atコマンドを使用したい場合に利用 |
| smartd | ハードディスクの内蔵の自己診断機能(S.M.A.R.T.)を利用し、異常が発生したときにレポートするデーモン。RAIDを使わないので無効 |
| haldaemon | システム上のハードウェアに関していくつかのソースから情報を集めたり管理したりするデーモン。デスクトップ環境ではないので無効 |
| restorecond | SELinuxと連動して、ファイルの作成などを監視して適当なラベルを付与するがSELinuxは無効なので、こちらも無効化 |
参考サイト : 不要なサービスは停止~ソフトウェアRAIDモニター(mdmonitor) : 不要なサービスは停止~HALデーモン(haldaemon) : 不要なデーモンを停止させる (CentOS 6.5) : 不要なデーモンを停止しましょう
2.設定変更したlevel設定の確認
# chkconfig --list |sort -s
offにしたサービスが起動していないことを確認
