出荷された状態では、ssh rootログインが許可されているので、無効にする。また、日常で作業用のログインするアカウントを作成し、鍵認証のみでログインを許す。
更に、hosts.allowに記述して、接続許可するIPアドレスを書いても良いだろう。
# groupadd -g 999 admin # useradd -g admin -g admin -G wheel -m admin
ログイン用パスワードを付けるか、パスワードを無効にします。
# passwd admin <- 新しいsshは、passwdが付いていないとログインが拒否される
or
# vipw (shadow passの変更) --- admin:$1.....:14141:0:99999:7::: ↓ admin:*:14141:0:99999:7:::
注意: パスワードを潰した場合、パスワード認証及び、sudoの時、パスワード確認が出来なくなりますので注意が必要です。
公開鍵を設置します
mkdir -p /home/admin/.ssh touch /home/admin/.ssh/authorized_keys chown -R admin:admin /home/admin chmod 700 /home/admin ; chmod /home/admin/.ssh chmod 600 /home/admin/.ssh/authorized_keys vi /home/admin/.ssh/authorized_keys --- 自分の鍵を入れてください
この状態で、新しいセッション(ターミナル)を開き、正常に鍵認証でsshログインが出来るか確認します。
# passwd root Changing password for user root. New UNIX password: <- 新しいパスワード Retype new UNIX password: <- 新しいパスワード(確認用) passwd: all authentication tokens updated successfully.
出荷された状態では、ssh rootログインが許可されているので、無効にする。
# vi /etc/ssh/sshd_config ---- PermitRootLogin no PubkeyAuthentication yes PasswordAuthentication no UsePAM no
今回、スケーラブルプランでは、IPアドレスが2つ割り当てられているので、サービス用とssh/dnsといった用途に応じて、LISTENさせるIPアドレスを設定してもよいでしょう。両方のアドレスでsshdをLISTENさせる必要は有りません。片方で十分です。
ListenAddress 115.146.17.***
初期状態では、ミラーサーバを使うようになっていますが、遅いので近くのサーバを使います。
下記の例ではデフォルトのファイルをバックアップを作成し、IIJのミラーサーバを利用するようにしています。
、
# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.orig # cat > /etc/yum.repos.d/CentOS-Base.repo ---- # CentOS-Base.repo # # This file uses a new mirrorlist system developed by Lance Davis for CentOS. # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ baseurl=http://ftp.iij.ad.jp/pub/linux/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 #released updates [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ baseurl=http://ftp.iij.ad.jp/pub/linux/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 #packages used/produced in the build but not released [addons] name=CentOS-$releasever - Addons #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons #baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/ baseurl=http://ftp.iij.ad.jp/pub/linux/centos/$releasever/addons/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ baseurl=http://ftp.iij.ad.jp/pub/linux/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ baseurl=http://ftp.iij.ad.jp/pub/linux/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
最新版へアップデートをしましょう
# yum update
rotateするファイル数を999個分アーカイブを、ファイルはgz圧縮するように設定します。
この辺は環境に応じて変更して下さい。
(gz圧縮をすることをお勧めします。特にApacheとか使用した場合、ログファイルは直ぐに肥大化しますから…。)
# vi /etc/logrotate.conf ---- rotate 4 ↓ rotate 999
# compress ↓ compress
個人的な偏見の元にチョイスしていますが、次のような物があると非常に便利です。
出荷状態では、logwatch, syslogd といった物も入っていません。
# yum install sysklogd lv bind-utils w3m mailx sysstat logwatch