VPSのサーバにログインしたら、まずやること
VPSでサーバにログインしたらとりあえずすること、毎回だいたいこんな流れかな、と思うので。
まずはrootユーザのパスワードを変更
# passwd
アップデート可能な全パッケージをアップデート
# yum check-update # yum -y update
操作用のユーザを用意
# useradd -c "HOGE user" -d /home/hoge -m -g users hoge # usermod -g users -G wheel hoge # passwd hoge
もし、新たに鍵を作るなら
# su - hoge $ ssh-keygen -t rsa $ cd ~/.ssh $ cat id_rsa.pub >> authorized_keys $ chmod go-rwx authorized_keys $ exit
ここでリモートから、上記ユーザで(鍵認証の)ログインができるか確認
sudoの動作を設定
# cd /etc # cp -p sudoers sudoers.ORG # visudo # diff -c sudoers.ORG sudoers 92a93 > %wheel ALL=(ALL) NOPASSWD: ALL
SSH経由でのrootユーザのログインを禁止
# cd /etc/ssh # cp -p sshd_config sshd_config.ORG # vi sshd_config
MTAをPostfixに変更
# yum -y install postfix # /etc/rc.d/init.d/sendmail stop # chkconfig --level 2345 sendmail off # update-alternatives --display mta # update-alternatives --config mta # cd /etc/postfix # vi main.cf # diff main.cf.ORG main.cf 417a418 > mail_spool_directory = /var/spool/mail/ # /etc/rc.d/init.d/postfix start
とりあえず必要ないポートは全て閉じる
# sh ~/iptables.sh # /etc/rc.d/init.d/iptables status # /etc/rc.d/init.d/iptables save
vimをインストール
# yum install vim-common vim-enhanced vim-minimal
CentOSの開発版のレポジトリを使えるように
# vi /etc/yum.repos.d/CentOS-Testing.repo
中身はこんな
# CentOS-Testing: # !!!! CAUTION !!!! # This repository is a proving grounds for packages on their way to CentOSPlus and CentOS Extras. # They may or may not replace core CentOS packages, and are not guaranteed to function properly. # These packages build and install, but are waiting for feedback from testers as to # functionality and stability. Packages in this repository will come and go during the # development period, so it should not be left enabled or used on production systems without due # consideration. [centos5-testing] name=CentOS-5 Testing baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/ enabled=0 gpgcheck=1 gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing includepkgs=php* priority=1