* セキュリティ対策 [#o3305dcf]
 
 出荷された状態では、ssh rootログインが許可されているので、無効にする。また、日常で作業用のログインするアカウントを作成し、鍵認証のみでログインを許す。
 
 更に、hosts.allowに記述して、接続許可するIPアドレスを書いても良いだろう。
 
 
 ** 作業用のログインアカウントを作成 [#k92dd90c]
 
  # 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ログインが出来るか確認します。
 
 
 ** sudoの設定 [#reb5a9d4]
 
 ここでの設定方針は色々と有りますので、詳しくは触れません。~
 %wheelグループを全てsudoが使えるようにするという考えもあります。~
 尚、shadowを編集し、ユーザアカウントのパスワードが無効になっている場合、NOPASSWD: ALL にする必要があります。
 
 
  # visudo
   ----
  admin  ALL=(ALL)       ALL
 
 
 
 ** root パスワードの変更 [#jb9e7764]
 
  # passwd root
   Changing password for user root.
   New UNIX password:   <- 新しいパスワード
   Retype new UNIX password:  <- 新しいパスワード(確認用)
   passwd: all authentication tokens updated successfully.
 
 
 
 ** SSHのrootログインを無効、鍵認証にする [#xb46b611]
 
 出荷された状態では、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.***
 
 
 ** 最新版へアップデート [#e9ee28a5]
 
 *** /etc/yum.repos.d/CentOS-Base.repo の書き換え [#kd0c36ab]
 
 初期状態では、ミラーサーバを使うようになっていますが、遅いので近くのサーバを使います。~
 下記の例ではデフォルトのファイルをバックアップを作成し、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 [#p60853b5]
 
 最新版へアップデートをしましょう
 
  # yum update
 
 
 
 
 * 基本設定 [#r2dcabe7]
 
 ** 有ると便利なパッケージ群 [#y657f6c3]
 
 個人的な偏見の元にチョイスしていますが、次のような物があると非常に便利です。~
 出荷状態では、logwatch, syslogd といった物も入っていません。
 
  # yum install sysklogd lv bind-utils w3m mailx sysstat logwatch
 
 
 
 
 ** logrotate の設定 [#m38475af]
 
 rotateするファイル数を999個分アーカイブを、ファイルはgz圧縮するように設定します。~
 この辺は環境に応じて変更して下さい。~
 (gz圧縮をすることをお勧めします。特にApacheとか使用した場合、ログファイルは直ぐに肥大化しますから…。)
 
 
  # vi /etc/logrotate.conf
   ----
  rotate 4
    ↓
  rotate 999
 
  # compress
    ↓
  compress
 
 
 
 ** 有ると便利なパッケージ群 [#y657f6c3]
 ** localeの設定etc [#s54d743e]
 
 個人的な偏見の元にチョイスしていますが、次のような物があると非常に便利です。~
 出荷状態では、logwatch, syslogd といった物も入っていません。
 デフォルトではutf-8になっているので必要に応じてCに変更して下さい。
 
  # yum install sysklogd lv bind-utils w3m mailx sysstat logwatch
 
 
 ** 自動updateの設定 [#j5dba276]
 
 Parallels Power Panel に、アップデート機能があるため、こちらでおこなう必要は特別ないと思いますが…自動化したい人のために。
 
 CPIのvpsには、/etc/init.d/yum が有りません。~
 すなわち自動updateの設定がここでは出来ませんので、必要な人は、cronに、yum updateをするか、yum check-updateをするように仕掛けておいても良いかも知れません。
 
 
 ''参考''
 
 CentOS4では...
 
  # cat /etc/cron.daily/yum.cron
  ----
  #!/bin/sh
  
  if [ -f /var/lock/subsys/yum ]; then
          /usr/bin/yum -R 120 -e 0 -d 0 -y update yum
          /usr/bin/yum -R 10 -e 0 -d 0 -y shell /etc/yum/yum-daily.yum
  fi
 
  # cat /etc/yum/yum-daily.yum
  ----
  update
  ts run
  exit
 
 initスクリプトにより、yumのサービスをstartすると、/var/lock/subsys/yum に空ファイルが作成され、それがあると上記のスクリプトが実行されるようになっています。
 
TOPページへ戻る   新しいページの作成新しい下位ページの作成そのページを引用して新規作成ページ名の変更ページへのリンク元を表示   サイトのページ一覧サイト内単語検索編集したページの履歴削除したページの履歴   別ウィンドウでマニュアルページへ