Debianインストール直後
X60sとDebianとDebianとWPA-PSKとwpa_supplicantと固定IPに引き続き、インストール後の設定。
Debianのアップデート
# resynchronize the package index files from their sources apt-get update # install the newest versions of all packages currently installed on the system from the sources apt-get upgrade # remove packages that were automatically installed to satisfy dependencies for some package and that are no more needed apt-get autoremove # clears out the local repository of retrieved package files apt-get clean # updates the package cache and checks for broken dependencies apt-get check
sshの設定
通常はネットワーク経由で作業を行うため、ssh の設定を行い、以降は ssh 経由で作業を行う。
作業者のSSH認証用設定
作業者全員分の公開鍵を設定する。以下例:
USER_NAME="作業者のユーザー名" PUB_KEY="作業者の公開鍵" mkdir /home/$USER_NAME/.ssh chmod 700 /home/$USER_NAME/.ssh echo $PUB_KEY > /home/$USER_NAME/.ssh/authorized_keys chmod 600 /home/$USER_NAME/.ssh/authorized_keys chown -R $USER_NAME:$USER_NAME /home/$USER_NAME/.ssh
sshdの設定
- ポート番号を 22 から別の番号に変更(今回は56789番ポートとする)
- ssh接続時のrootログインを禁止
- パスワード認証を禁止
以下はviで目視確認しながら置換を行う例:
vi /etc/ssh/sshd_config :%s/Port 22/Port 56789/gc :%s/PermitRootLogin yes/PermitRootLogin no/gc :%s/#PasswordAuthentication yes/PasswordAuthentication no/gc
sshdの再起動
/etc/init.d/ssh restart
sshd の再起動後、公開鍵認証でログインできるかを確認する。
iptablesの設定
設定ファイルの作成
以下を実行して設定ファイルを /etc/network/if-pre-up.d/iptables-setup に作成する。*1
echo '#!/bin/sh ### initialize ### /sbin/iptables -F # テーブルを初期化 /sbin/iptables -X # チェーンを削除 ### policies ### /sbin/iptables -P INPUT DROP # 基本的に外部からのパケットは基本的に無視する。 /sbin/iptables -P OUTPUT ACCEPT # 基本的に内部で生成されたパケットは基本的に処理する。 /sbin/iptables -P FORWARD DROP # 基本的にパケットのルーティングは行わない。 ### rules ### /sbin/iptables -A INPUT -p TCP -s 0/0 --dport 80 -j ACCEPT # tomcat /sbin/iptables -A INPUT -p TCP -s 0/0 --dport 443 -j ACCEPT # tomcat(ssl) /sbin/iptables -A INPUT -p TCP -s 0/0 --dport 56789 -j ACCEPT # ssh /sbin/iptables -A INPUT -p ICMP -s 0/0 --icmp-type 8 -j ACCEPT # icmp /sbin/iptables -A INPUT -p ICMP -s 0/0 --icmp-type 11 -j ACCEPT # icmp /sbin/iptables -A INPUT -p ALL -i lo -s 127.0.0.1 -j ACCEPT # ローカルループバックからの入力は許可 /sbin/iptables -A INPUT -p ALL -m state --state ESTABLISHED,RELATED -j ACCEPT # セッション確立後のパケット疎通は許可' > /etc/network/if-pre-up.d/iptables-setup chmod 755 /etc/network/if-pre-up.d/iptables-setup
フィルタリングの手動実行
/etc/network/if-pre-up.d/iptables-setup
ntpの設定
ntpのインストール
yes | apt-get install ntp
設定ファイルの変更
/etc/ntp.conf ファイルの下記の箇所を
server 0.debian.pool.ntp.org iburst server 1.debian.pool.ntp.org iburst server 2.debian.pool.ntp.org iburst server 3.debian.pool.ntp.org iburst
下記の内容に置き換える
server ntp1.jst.mfeed.ad.jp server ntp2.jst.mfeed.ad.jp server ntp3.jst.mfeed.ad.jp
ntpdの再起動
/etc/init.d/ntp restart
その他必要なパッケージのインストール
自分が必要と思うパッケージを思うままに入れる。
vim のインストール
yes | apt-get install vim echo 2 | update-alternatives --config editor update-alternatives --config editor # /usr/bin/vim.basic が選択されていることを確認して CTRL+C
pbzip2 のインストール
apt-get install bzip2