※注意!
サーバの時間が狂っていると、CAファイルの時間がおかしくなり、CAファイルが開始日前とかになる可能性があります。NTPコマンドで、時間を正しくしましょう!
# ntpdate ntp.jst.mfeed.ad.jp
OpenSSL、PAMはCentOS 5.2の最小構成で入るので無視。次に、LZOをyumで入れようとするとデフォルトではナシ。仕方がないので、本家のrpmを拝借してくる。あと、OpenVPNも同時に入れちゃう。
sudo rpm -ihv http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-2.noarch.rpm
sudo yum install lzo
sudo yum install openvpn
■SSL/TLS証明書を作ろう!
OpenVPNをパッケージでインストールすると、/usr/share/openvpn/easy-rsa/ に、その関連ファイルがコピーされる。これを、/etc/openvpn/ にコピーしておく。パッケージアップデートで消されたら、たまらんし。
sudo cp -R /usr/share/openvpn/easy-rsa/ /etc/openvpn
[xxx@localhost openvpn]$ pwd
/etc/openvpn
[xxx@localhost openvpn]$ ls -la
合計 24
drwxr-xr-x 3 root root 4096 1月 26 20:53 .
drwxr-xr-x 76 root root 4096 1月 26 20:37 ..
drwxr-xr-x 4 root root 4096 1月 26 20:53 easy-rsa
□CAを作ろう!
何故か、2.0と1.0というディレクトリが存在する。たぶん、2.0が正解だと思われ。次に、vars ファイルを編集する。
cd /etc/openvpn/easy-rsa/2.0
export KEY_COUNTRY="JP" ← 日本
export KEY_PROVINCE="TOKYO" ← 都道府県名
export KEY_CITY="Shibuya" ← 住所の一部
export KEY_ORG="hogehoge" ←会社名
export KEY_EMAIL=”hogehoge@hogehoge.co.jp” ←担当者メアド
vars に実行権限を与える。
sudo chmod +x vars
root権限になり、/etc/openvpn/easy-rsa/2.0 に移動。
sudo su –
cd /etc/openvpn/easy-rsa/2.0
CAを作成する。基本的にエンターだけでいけるはず。
source ./vars
./clean-all
./build-ca
Common Name (eg, your name or your server’s hostname) の所で、「OPEN_VPN」に書き換える。
□サーバ証明書を作ろう!
root/今のPATHのまま、以下のコマンドを実行する。
./build-key-server server
Common Name (eg, your name or your server’s hostname) で、「VPN_SERVER」に書き換える。[y/n]の選択肢は、全て[y]で。
□DH(Diffie Hellman)パラメータを作ろう!
OpenVPNサーバが、クライアントと鍵を交換する際に、暗号化用の乱数値が必要らしい。その乱数値を作る。DHとは、開発者にちなんでいるらしい。
./build-dh
本には、「時間がかかる」と書かれていたが、Celeron 2.53GHz / 1GBでは数秒で終わった。
□クライアント証明書を作ろう!
クライアントをどう管理するか? 名前ファイルか、client1とか付けて、Excelで管理するか。まあ、ちょっと悩んでくれ(汗
今回は、とりあえず client1 とかで作る事にする。
./build-key-pass client1
Generating a 1024 bit RSA private key
………………………++++++
…………………++++++
writing new private key to ‘client1.key’
Enter PEM pass phrase: [パスワード]
Verifying – Enter PEM pass phrase: [パスワード]
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [JP]:
State or Province Name (full name) [TOKYO]:
Locality Name (eg, city) [Shibuya]:
Organization Name (eg, company) [hogehoge]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server’s hostname) [client1]:
Name []: [担当者名]
Email Address [担当者メールアドレス]:Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []: [パスワード:クライアント起動時のパス]
An optional company name []:
Using configuration from /etc/openvpn/easy-rsa/2.0/openssl.cnf
Check that the request matches the signature
Signature ok
The Subject’s Distinguished Name is as follows
countryNameRINTABLE:’JP’
stateOrProvinceNameRINTABLE:’TOKYO’
localityNameRINTABLE:’Shibuya’
organizationNameRINTABLE:’hogehoge’
commonNameRINTABLE:’client1′
nameRINTABLE:’[担当者名]‘
emailAddress :IA5STRING:’[担当者メールアドレス]‘
Certificate is to be certified until Jan 24 12:29:53 2019 GMT (3650 days)
Sign the certificate? [y/n]:y ← 普通に[Yes]1 out of 1 certificate requests certified, commit? [y/n]y ← 普通に[Yes]
Write out database with 1 new entries
Data Base Updated
/etc/openvpn/easy-rsa/2.0/keys の配下にファイルがいっぱいできる。重要なのは「*.crt」と「*.key」です。
[以下、CentOS 5.2 に OpenVPN を突っ込むテスト[2]へ]





ピンバック: わがまま大王@みらにすた - CentOS 5.2 に OpenVPN を突っ込むテスト[2]
ピンバック: わがまま大王@みらにすた - CentOS 5.2 に OpenVPN を突っ込むテスト[7]