FreeBSDに係わる構築や維持など

Archive for 10月, 2006

仮想FreeBSDマシン Jail環境構築

 FreeBSDにて、chroot(8)を強化したJailを使って、Jail環境内にサービスを構築してみることを目標にしてみたいと思う。jailの導入はportsからezjailを用います。

構成は下記のような感じですが、テストを兼ねてWindows上のVMwareにFreeBSDが乗っかってます。
ホストOS WindowsXP
ゲストOS FreeBSD 6.1

 
IPアドレス
ホスト名
FQDN
root directory
host環境 192.168.111.101 host
vmtest.vm.selfip.com
/
jail環境 192.168.111.201 test
jail.vm.selfip.com
/usr/jails/test

Read more »

rep2 機能拡張パックを入れる

rep2 機能拡張パック

$ unzip rep2ex-060903-0030.zip
$ unzip p2pear-37.zip
$ cd rep2ex-060903-0030/
# cp -rp rep2 /usr/local/www/apache22/data

# mkdir /usr/local/www/apache22/data/rep2/includes
# cd ../p2pear/includes
# cp -rp * /usr/local/www/apache22/data/rep2/includes/

Read more »

freebsd-update をつかってセキュリティブランチで追いかける

$ uname -rsm
FreeBSD 6.1-RELEASE i386

port から freebsd-update をインストール

# portinstall security/freebsd-update

Before you can use this, you will have to create an update configuration
file specifying the server to fetch updates from and the trusted public
key fingerprint.

A sample configuration file has been installed in

       /usr/local/etc/freebsd-update.conf.sample

which will fetch updates built by the author.  If you trust the author
to securely build binary updates for you to blindly install on this
machine, copy that file to

       /usr/local/etc/freebsd-update.conf

otherwise, create that file as appropriate.
===>   Compressing manual pages for freebsd-update-1.6_2
===>   Registering installation for freebsd-update-1.6_2
===>  Cleaning for freebsd-update-1.6_2

Read more »

OpenSSH

inetdからもsshdが起動されるようであれば、コメントをつける

# vi /etc/rc.conf

#sshd_enable="YES"
inetd_enable="YES"

# cat /etc/inetd.conf |grep ssh
ssh     stream  tcp     nowait  root    /usr/sbin/sshd          sshd -i -4
#vi /etc/ssh/sshd_config
Port 22 #SSHプロトコル2での接続に限る
Protocol 2 #rootユーザーからのログインを禁止する
PermitRootLogin no #PasswordAuthentication,PermitRootLoginの効果に影響する。
PubkeyAuthentication yes #公開鍵方式の認証を使用できるようにする(SSH2)
RhostsRSAAuthentication yes #RSAホスト間の認証で.rhosts、/etc/hosts.equivを無視する(SSH2)
PasswordAuthentication no #loginパスワード認証を使用しない
PermitEmptyPasswords no #空のパスワードを禁止する
ChallengeResponseAuthentication no #PasswordAuthentication,PermitRootLoginの効果に影響する。

# /etc/rc.d/sshd restart

SSHの認証方式
大きくわけて、ホストベース認証とユーザー認証の二通りがある。
ユーザー認証には、パスワード認証と公開鍵認証の二通りがあります。

鍵の作成(いろいろ)

SSH1 RSA $ssh-keygen -t rsa1
SSH2 DSA $ssh-keygen -t dsa
SSH2 RSA $ssh-keygen -t rsa
鍵の種類 公開鍵ファイル 秘密鍵ファイル
SSH1 RSA ~/.ssh/identity.pub ~/.ssh/identity
SSH2 RSA ~/.ssh/id_rsa.pub ~/.ssh/id_rsa
SSH2 DSA ~/.ssh/id_dsa.pub ~/.ssh/id_dsa

鍵ペアを作成する

# su donatasama

$ ssh-keygen -t rsa
Generating public/private rsa key pair.

Enter file in which to save the key (/home/donatasama/.ssh/id_rsa): Created directory '/home/donatasama/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/donatasama/.ssh/id_rsa.
Your public key has been saved in /home/donatasama/.ssh/id_rsa.pub.
The key fingerprint is:
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx donatasama@donatasama

公開鍵を接続先マシンに登録する

$ cd ~/.ssh/
$ mv id_rsa.pub authorized_keys
$ chmod 600 authorized_keys

$ cat authorized_keys
を
接続先の公開鍵に追加する

UTF-8 TeraTerm Proの設定

>get id_rsa

ショートカットを作成し、自動ログインできるようにする

リンク先
"C:\Program Files\teraterm\ttermpro.exe" donatasama /ssh /2 /auth=publickey /user=donatasama /passwd=donatasama /keyfile=C:\secret\id_rsa-donatasama