
วันนี้หลายคนคงรู้จักระบบ Authentication server หลายตัว แต่ตัวนี้อาจยุ่งอยากในการติดตั้งสักนิดแต่ใช้ร่วมกับระบบอื่นได้มากกว่า
ขั้นตอนที่ 1 เตรียมติดตั้ง DHCP ให้ระบบ
#yum install dhcp
1. ทำการสร้าง dhcpd.conf
#cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
* ทำการแก้ไขตามกลุ่มเครือข่ายที่กำหนดไว้
#vim /etc/dhcpd.conf
หมายเหตุ ขั้นตอนการใช้ vi และ vim ขอข้ามในช่วงหลัง กด I เพื่อทำการ Insert
ddns-update-style interim;
ignore client-updates;
DHCPARGS=eth1;
subnet 200.0.0.0 netmask 255.255.255.0 {
# --- default gateway
option routers 200.0.0.1;
option subnet-mask 255.255.255.0;
option domain-name "coe.psu.ac.th"; # name server isp
option domain-name-servers 172.30.0.5;
option domain-name-servers 172.30.0.9;
option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
range dynamic-bootp 200.0.0.100 200.0.0.200;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
หมายเหตุ ขั้นตอนการใช้ vi และ vim ขอข้ามในช่วงหลัง เมื่อกำหนดค่าเสร็จเรียบร้อย Esc+ “:wq” เพื่อทำการบันทึก
#chkconfig dhcpd on
#/etc/init.d/dhcpd start
#chkconfig httpd on
#/etc/init.d/httpd start
ข้อตอนที่ 2. การเตรียม SSL สำหรับ Apache
#yum install mod_ssl openssl
บรรทัดนี้ Generate private key ทำการสร้าง Generate CSR
#openssl genrsa -out ca.key 1024
#openssl req -new -key ca.key -out ca.csr
ขอขยายความนะ ครับ
Country Name (2 letter code) [XX]: TH >Enter
State or Province Name (full name) []:SK >Enter
Locality Name (eg, city) [Default City]: >Enter
Organization Name (eg, company) [Default Company Ltd]: >Enter
Organizational Unit Name (eg, section) []: test >Enter
Common Name (eg, your name or your server's hostname) []: test.com >Enter
Email Address []:admin@test.com >Enter
A challenge password []: >Enter
An optional company name []: >Enter
ทำการสร้าง Generate Self Signed Key
#openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt
ทำการย้าย files ไปยังที่สำหรับกำหนด
#mv ca.crt /etc/pki/tls/certs
#mv ca.key /etc/pki/tls/private/
#mv ca.csr /etc/pki/tls/private/
ทำการแก้ไขไฟล์
#vim +/SSLCertificateFile /etc/httpd/conf.d/ssl.conf
ทำการแก้ไข บรรทัดต่อไปนี้ให้เป็นตามที่กำหนด
SSLCertificateFile /etc/pki/tls/certs/ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
เสร็จกระบวนการแล้วให้ทำการ restart service ใหม่
#/etc/init.d/httpd restart
หากต้องตรวจสอบให้ทำการเรียกผ่านเว็บที่เครื่องลูกข่าย https://IP Server/ ถ้าเรียกขึ้นแสดงว่า Web server รองรับ ssl แต่หากเรียกไม่ผ่าน หรือ ฟ้อง Error ให้ทดลองอ่านเพิ่มเติมดู ที่
http://wiki.centos.org/HowTos/Https
ขั้นตอนที่ 3 ติดตั้ง NoCat Authen
เตรียมความพร้อมโดยติดตั้ง โปรแกรมสนับสนุนเพิ่มก่อน
#yum install perl*
#yum install gnupg
เข้าสู่กระบวนการติดตั้ง
Download with command
#wget http://nocat.net/download/NoCatAuth/NoCatAuth-nightly.tgz
#cp NoCatAuth-nightly.tgz /root
#cd /root
#tar zxvf NoCatAuth-nightly.tgz
#cd NoCatAuth-nightly
ทำการปรับค่า Linux จาก 2.4 เป้น 2.6
#vim bin/detect-fw.sh
ทำการแก้ไข เลข 2.4 เป็น 2.6
ขั้นตอนสำหรับการติดตั้ง gateway และ Authen แบบ Same Machine
#make PREFIX=/usr/local/nocat/gw gateway
#make PREFIX=/usr/local/nocat/authserv authserv
#make PREFIX=/usr/local/nocat/authserv pgpkey
------------------------------------------------------------------------------------
Looking for gpg...
[ -d /usr/local/nocat/authserv/pgp ] || mkdir /usr/local/nocat/authserv/pgp
chmod 700 /usr/local/nocat/authserv/pgp
gpg --homedir=/usr/local/nocat/authserv/pgp --gen-key
gpg (GnuPG) 1.4.7; Copyright (C) 2006 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
gpg: keyring /usr/local/nocat/authserv/pgp/secring.gpg' created
gpg: keyring /usr/local/nocat/authserv/pgp/pubring.gpg' created
Please select what kind of key you want:
(1) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)
Your selection?
DSA keypair will have 1024 bits.
ELG-E keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
= key expires in n days
w = key expires in n weeks
m = key expires in n months
y = key expires in n years
Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) y
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) "
Real name: Authenication server
Name must be at least 5 characters long
Email address: admin@yourdomain.com
Comment: WIFI Authen
You selected this USER-ID:
"Authenication server (WIFI Authen) "
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
You need a Passphrase to protect your secret key.
You don't want a passphrase - this is probably a *bad* idea!
I will do it anyway. You can change your passphrase at any time,
using this program with the option "--edit-key".
--------------------------------------------------------------------------------------------------
ระหว่างนี้ระบบจะแนะนำให้กด แป้น Keyboard ไปเรื่อย ๆ เพื่อไม่ให้ระบบเข้าสู่ sleep mode ไม่นานครับไม่เกิน 1 นาที อดทนนิดนึง
gpg: /usr/local/nocat/authserv/pgp/trustdb.gpg: trustdb created
gpg: key ACF06752 marked as ultimately trusted
public and secret key created and signed.
gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
pub 1024D/ACF06752 2007-10-20
Key fingerprint = 7A1A BC17 C129 8894 AEFD BAA4 4F31 0B7A ACF0 6752
uid Authenication server (WIFI Authen)
sub 2048g/ABD7FC22 2007-10-20
cp -R /usr/local/nocat/authserv/pgp/pubring.gpg /usr/local/nocat/authserv/trustedkeys.gpg
cp -R /usr/local/nocat/gw/pgp/pubring.gpg /usr/local/nocat/authserv/trustedkeys.gpg
The public key ring you'll need to distribute can be found in
/usr/local/nocat/authserv/trustedkeys.gpg.
เมื่อเสร็จกระบวนการมีบรรทัดด้านบนปรากฏ
*** ควรตรวจสอบว่า Directory /usr/local/nocat/authserv/pgp สามารถเขียนอ่านได้นะครับ
ทำการย้ายไฟล์ key ไป พร้อมเปลี่ยนสิทธิการใช้งานให้กับ web service (Apache)
#cp /usr/local/nocat/authserv/trustedkeys.gpg /usr/local/nocat/authserv/pgp/
#cp /usr/local/nocat/authserv/trustedkeys.gpg /usr/local/nocat/gw/pgp/
#chown -R apache.apache /usr/local/nocat/authserv
#chown -R apache.apache /usr/local/nocat/gw
ขั้นที่ 4 ทำการเตรียม Mysql สำหรับบริหารจัดการผู้ใช้ระบบ
#chkconfig mysqld on
#/etc/init.d/mysqld start
#mysqladmin –u root password 123456
การเตรียมฐานข้อมูลสำหรับระบบ Nocat
#mysqladmin create nocat -p (and hit the password you set on Mysql admin)
#cd /root/NoCat..../etc
#mysql -u root -p nocat < nocat.schema
Install phpMyAdmin for management your mysql via web page
# wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/2.11.10.1/phpMyAdmin-2.11.10.1-all-languages.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fphpmyadmin%2Ffiles%2FphpMyAdmin%2F2.11.10.1%2F&ts=1312044975&use_mirror=cdnetworks-kr-2
# tar -zxvf phpMyAdmin-2.11.10.1-all-languages.tar.gz
# mv phpMyAdmin-2.11.10.1 phpmyadmin
#cp -R phpmyadmin /var/www/html/
#mv /var/www/html/phpmyadmin/config.sample.inc.php /var/www/html/phpmyadmin/config.inc.php
#vim /var/www/html/phpmyadmin/config.inc.php
Fix for secret passwordthis line
$cfg['blowfish_secret'] = 'testpassword';
Now you can use phpMyAdmin via web browser
ขั้นตอนที่ 5 การตั้งค่าให้กับ nocat
#vim /usr/local/nocat/authserv/nocat.conf
แก้ไขบรรทัดด้านล่างนี้
• HomePage http://www.yoursite.com
• DataSource DBI
• Database dbi:mysql:database=nocat
• DB_User nocat
• DB_Passwd 123456
#vim /usr/local/nocat/gw/nocat.conf
แก้ไขบรรทัดด้านล่างนี้
• GatewayName yourcompanyname
• GatewayMode Passive
• #GatewayLog /usr/local/nocat/gw/nocat.log (เพื่อระบุว่า ให้เก็บ log การใช้งานไว้ที่ใหน)
• LoginTimeout 86400 (ตัวอย่างกำหนดให้หมดเวลาใน 1 วัน)
• IdleTimeout 86400
• HomePage http://www.yoursite.com
• TrustedGroups Any
• Owners admin@yoursite.com
• AuthServiceAddr serveraddress (200.0.0.1)
• AuthServiceURL https://$AuthServiceAddr/cgi-bin/login
• LogoutURL https://$AuthServiceAddr/logout.html
• ExternalDevice eth0 (or the one you set)
• InternalDevice eth1 (or the one you set)
• LocalNetwork yourlannetwork (example 200.0.0.0/24)
• DNSAddr clarkconnectserveraddress(200.0.0.1 maybe)
• AllowedWebHosts somewebsiteaddress (google.com สามารถระบุเวบที่ต้องการให้เข้าโดยไม่ต้องผ่านการ authentication)
ทำหารตั้งค่าสำหรับระบบ Web service(Apache)
#cp /usr/local/nocat/authserv/httpd.conf /etc/httpd/conf.d/nocat.conf
#vim /etc/httpd/conf/httpd.conf
DocumentRoot "/usr/local/nocat/authserv/htdocs"
เปลี่ยน Directory "/var/www/html" - "/usr/local/nocat/authserv/htdocs"
(comment this line) #ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
A few lines under #ScriptAlias Change to
#vim /etc/httpd/conf.d/ssl.conf
แก้ไขบรรทัดด้านล่างนี้
"/var/www/cgi-bin/" == "/usr/local/nocat/authserv/cgi-bin"
ทำการกำหนดให้เครื่องเป็น foreward ออกภายนอก โดย
#vim /etc/sysctl.conf แก้ net.ipv4.ip_forward = 1
สำหรับการสร้างให้ Nocat เป็นเหมือน Service ทั่วไป
#cd /root
#wget http://trip.ge.infn.it/software/config_file/nocat/nocatgw
#cp /root/nocatgw /etc/init.d/
#chkconfig --add nocatgw;
#/etc/init.d/nocatgw start
*** หากต้องการให้ใช้ กับการเปิดอัตโนมัติให้ใช้ ตัวอย่างไฟล์ Script จากที่นี่ http://trip.ge.infn.it/software/config_file/nocat/nocatgw
ขั้นตอนที่ 6 การเพิ่มผู้ใช้ระบบ
/usr/local/nocat/authserv/bin/admintool -c user01 123456
/usr/local/nocat/authserv/bin/admintool -a user01 member
Link อ้างอิง(ที่ทำให้เกิดเอกสารฉบับนี้)
http://shapeshed.com/journal/setting_up_mod_ssl_on_apache_centos_52/
http://kom.homelinux.org/node/295
http://trip.ge.infn.it/software/config_file/nocat/
ทดสอบ ตอนที่ 2. การเตรียม SSL สำหรับ Apache แล้วไม่ผ่านค่ะ
ตอบลบช่วยอธิบายว่าแต่ละบรรทัดคืออะไรให้หน่อยได้มั๊ยค่ะ..ขอบคุณล่วงหน้าค่ะ^^