openCA的安装

来源:互联网 发布:淘宝网松下洗衣机 编辑:程序博客网 时间:2024/05/16 15:47

 下载各种各样的安装程序包,可以到CPAN网站搜索:
http://search.cpan.org/
查找rpm包:
http://rpmfind.net/
下载putty for win32:
http://www.chiark.greenend.org.uk/%7Esgtatham/putty/
http://www.chiark.greenend.org.uk/~sgtatham/putty/
开源项目网站:
http://devel.it.su.se/
下载CSP:
http://devel.it.su.se/projects/CSP/
智能卡:
SmartCard library and applications
www.opensc.org
RPM包网站:
ftp://mdk.linux.org.tw/pub/mandrake-devel/cooker/i586/Mandrake/RPMS/perl-5.8.2-2mdk.i586.rpm
论坛:
www.linuxforum.net
www.linuxsir.org
www.linuxfans.org
iso下载:
www.linuxiso.org
新丝路:http://www.wormwang.net/
RockLinux:
www.rocklinux.org



安装rpm包:rpm -ivh xxx.rpm
升级rpm包:rpm -Uvh xxx.rpm
查询rpm包:rpm -qa|grep xxx
卸载rpm包:rpm -e xxx.rpm
查看服务:netstat
查看服务:netstat -tl
安装服务:chkconfig --level 2345 xxx on
启动服务:service xxx start
搜索文件:find / * |grep xxx >results
      vi results
      example: find / × |grep ssh >results
解压缩.bz2: bzip2 -d xxx.bz2
解压缩.tar: tar xvf xxx.tar
解压缩.tar.gz: tar zxvf xxx.tar.gz
重新载入文件:source xxxfile, 例如:更新环境变量:
# cd /etc
# source bashrc


安装软件包需要注意的问题                                                                  
最好在编译前和编译后都做一张系统中所有文件的列表,然后用"diff"命令去比较它们,
找出其中的差别并知道到底把软件安装在哪里。只要简单地在编译之前运行一下命令"find /* >OpenSSH1",
在编译和安装完软件之后运行命令"find /* > OpenSSH2",
最后用命令"diff OpenSSH1 OpenSSH2 > OpenSSH-Installed"找出变化。


安装OPENCA的顺序如下:

安装Tawie Linux套件;
------------------
安装时选装以下项:
MYSQL;
development;
network;
ftp;
sshd
ssh
其他可以不要。


安装完成后,继续安装其他包:
------------------------
首先使用rpm命令查询现在已经安装的mysql包:
# rpm -q mysql
然后安装光盘,装上所有没有安装的其他mysql包:
# mount /dev/cdrom /mnt/cdrom
# cd /mnt/cdrom/tawie/rpms
# ls my*
# rpm -ivh mysql-devel-4.0.15-3tr.i586.rpm
# rpm -ivh mysql-bench-4.0.15-3tr.i586.rpm
# rpm -ivh mysql-client-4.0.15-3tr.i586.rpm
# rpm -ivh mysql-libs-4.0.15-3tr.i586.rpm
# rpm -ivh mysql-shared-4.0.15-3tr.i586.rpm


启动FTP/MYSQL服务;
------------------
修订/etc/ftpusers,注释掉ftp,即在ftp前加#号;
# cd /etc
# vi ftpusers
# cd /home/ftp
# chmod 777 pub -R
# chkconfig --level 2345 ftpd on    //加入自启动;
# chkconfig --level 2345 mysql on   //加入自启动;
# service ftpd start            //启动服务;
# service mysql start          //启动服务;

安装OPENSSH:
-------------------------------------
查看已经安装的SSH包:
# rpm -q ssh
# mount /dev/cdrom /mnt/cdrom
# cd /mnt/cdrom/tawie/rpms
# ls |grep ssh
# rpm -ivh openssh-xxx.xx.x.rpm //安装所有没有安装的ssh包;

配置sshd
---------------
替换配置文件:
# cd /etc/ssh
# ls
# cd /home/ftp/pub
# cp ssh_config /etc/ssh
# cp sshd_config /etc/ssh
编辑hosts.allow文件:

# cd /etc
# vi hosts.allow //加入:sshd: 132.147.19.68 wh1

SSH每用户配置(本部分只用于客户端为linux,客户端为win32,参考下面putty部分):
------------------------------------------
  每个用户在使用SSH之前,都要完成以下步骤:                                              
 1.在本地主机(比如,local.pku.edu.cn)上生成自己的ssh公钥和私钥。命令如下:
  local# ssh-keygen                                                        
  Generating 1024-bit dsa key pair                          
  1 oOo.oOo.o                                                                    
  Key generated.                                                              
  1024-bit dsa, teng@ns, F    ri Oct 20 2000 17:27:05
  Passphrase :************    /*在此输入你的口令,以后访问这台主机时要用。
  Again :************ /*                                              
  Private key saved to /home1/teng/.ssh2/id_dsa_1024_a
  Public key saved to /home1/teng/.ssh2/id_dsa_1024_a.pub

 2.生成的私钥和公钥(id_dsa_1024_a和id_dsa_1024_a.pub)存放在你家目录的~/.ssh2目录下。和用户
    相关的SSH配置文件都在~/.ssh2下。私钥由用户保存在本地主机上,而公钥需传送到远地主机的你自己的帐
    号的~/.ssh2下,如果你要用ssh2访问本地主机的话。
 
    在~/.ssh2下创建"identification"文件用来说明进行身份认证的私钥。命令如下:
 
       local:~/.ssh2# echo "IdKey id_dsa_1024_a" > identification
 
 3.同样地,在远地主机(比如,remote.pku.edu.cn)上完成上面步骤。       

 4.将本地(local.pku.edu.cn)下你自己(这里是"teng")的公钥(id_dsa_1024_a.pub)拷贝到远地主
     机(remote.pku.edu.cn)上你自己家目录下的.ssh2目录下,可命名为"local.pub",一般用ftp上传即可.
    
     在远地主机上,你自己家目录的.ssh2目录下,创建"authorization"文件,其中指定用来进行身份认证的公钥文件。
     命令如下:
    
       remote:~/.ssh2# echo "Key local.pub" > authorization
    
  现在你可以从本地用ssh2登录到远地系统了。命令如下:                                   
  local# ssh remote.pku.edu.cn                                 
  Passphrase for key "/home1/teng/.ssh2/id_dsa_1024_a" with comment "1024-bit dsa,
  teng@ns, Fri Oct 20 2000 17:27:05":***********
  这时会要你输入你的ssh口令(Passphrase)。验证通过后,即登录到remote主机上。

 5.改变pass-phrase                                                               
  用加上"-p"参数的"ssh-keygen"命令,在任何时候都可以改变pass-phrase。用下面的命令,改变pass-phrase:   
  [root@deep]# su username                                         
  [username@deep]$ ssh-keygen1 -p                           
  Enter file key is in (/home/username/.ssh/identity): [按下回车键]
  Enter old passphrase:                                               
  Key has comment username@deep.openarch.com     
  Enter new passphrase:                                               
  Enter the same passphrase again:                         
  Your identification has been saved with the new passphrase.



安装putty for win32软件包
----------------
1.安装putty;
2.使用puttygen产生密钥对(注意产生的版本ssh1,ssh2不能兼容),保存,直接保存的是ssh.com形式的公钥文件,
  不能用于openssh,所以需要将公钥内容信息文本框中的全部内容选中,然后拷贝,粘贴到一个新建的文本文件当中,
  保存该文本文件,命名为:authorized_keys;
 
3.将公钥文件authorized_keys上传给服务器,放到用户目录下的.ssh目录下,一般用ftp上传即可.
  注意.ssh目录的权限:
  # cd /root
  # mkdir .ssh
  # cd /home/ftp/pub
  # cp authorized_keys /root/.ssh
  # cd /root
  # chmod 644 .ssh -R
      
4.使用pageant,加入前面保存的用户私钥文件,直接使用保存的.PPK结尾的文件即可;

5.使用putty登录服务器,在SSH-AUTH中选中:authentication methods:全部选中,allow agent forwarding:选中。


启动SSHD服务:
---------
# chkconfig --list sshd
# chkconfig --level 2345 sshd on
# service sshd start


安装PERL;
---------------
首先升级所有已经安装的perl5.8.0的软件包和程序:
# rpm -qa|grep perl  //查询所有已经安装的perl包;
# rpm -Uvh perl-5.8.2.rpm  //最好先升级rpm包到想安装的版本;
注意:不是同一个发行套件的rpm包很难成功升级;

然后,安装5.8.0,在LFS_PACKAGES_5.0.ISO、lfs-packages-5.0.tar中都有perl-5.8.0.tar.bz2包:
bzip2 -d perl-5.8.0.tar.bz2
tar xvf perl-5.8.0.tar
cd perl-5.8.0
./Configure -des -Dusethreads
make
make test
make install

修改perl目录权限:
# cd /usr/local/lib/perl5/site_perl/
# chmod 777 5.8.0 -R

替换原有的perl执行文件:
# whereis perl
# perl -v
# cd /usr/bin
# ls -l perl*
如果安装同版本
可忽略这两步:
    # cd /usr/local/bin
    # cp perl* /usr/bin //用新的版本替换

测试perl的版本:
# whereis perl
# perl -v
# perl -V
----------------------------
安装liblocale-gettext-perl_1.01.orig.tar.gz
# cd /home/ftp/pub
# cp liblocale-gettext-perl_1.01.orig.tar.gz /usr/local
# tar zxvf liblocale-gettext-perl_1.01.orig.tar.gz
# cd liblocale-gettext-perl_1.01.orig
# perl Makefile.PL
# make
# make test
# make install
# shutdown -r now


安装OPENSSL;
-------------------------------
./config 
make
make test
make install

安装完成后,替换原来的openssl文件:
# cd /usr/local/ssl/bin
# cp openssl /usr/bin



安装CSP:
------------------
首先需要安装下列包,按顺序安装,有依赖关系:
Bit-Vector-6.3.tar.gz,
Date-Calc-5.3.tar.gz,
TermReadKey-2.21.tar.gz,
Term-Prompt-0.11.tar.gz;

命令都如下:
# perl Makefile.PL
# make
# make test
# make install

然后安装CSP-0.26.tar.gz;
# perl Makefile.PL
# make
# make install

需要设置环境变量:
# mkdir /home/ca
# export CSPHOME=/home/ca
# export OPENSSL=/usr/bin/openssl

测试环境变量:
# echo $CSPHOME
# echo $OPENSSL

为了方便将环境变量设置在/etc/bashrc 中:
# cd /etc
# vi bashrc
加入:
 export CSPHOME=/home/ca
 export OPENSSL=/usr/bin/openssl

测试是否ok:
# csp --help

参考/手册/cspguide.pdf;



安装下列DB包:
---------------
Data-Dumper-2.121.tar.gz
建议你首先安装Data-Dumper-?.??.tar.gz:(?.??是版本号,目前为2.09)

tar zxvf Data-Dumper-?.??.tar.gz 
将压缩文件接压缩到一个名为Data-Dumper-?.??的目录。
cd Data-Dumper-?.??
perl Makefile.PL
make
make test
make install
--------------------------------------------
Data-ShowTable-3.3.tar.gz
然后建议你安装Data-ShowTable-?.??.tar.gz:(?.??是版本号,目前为3.3)

tar zxvf Data-ShowTable-?.??.tar.gz
cd Data-ShowTable-?.??
perl Makefile.PL
make
系统会提示 ShowTable.pm 的724行I<....>有错误,所以需要先修订ShowTable.pm;
vi ShowTable.pm
修改如下:
原来724行:[, I</@title_formats [, I</@data_formats [, I<$table_attrs> ] ] ] ] ] ] ];
修改为:[, I</@title_formats> [, I</@data_formats> [, I<$table_attrs> ] ] ] ] ] ] ];
即加两个>括号;
重新make

make test
make install
---------------------------------------------------------------------
DBI-1.38.tar.gz
现在可以安装DBI-?.??:(?.??是版本号,目前为1.3)

tar zxvf DBI-?.??.tar.gz 
将压缩文件接压缩到一个名为DBI-?.??的目录。
cd DBI-?.??
perl Makefile.PL
make
make test
失败不要紧,再make test一次即可;
make install
----------------------------------------------------------------
DBD-mysql-2.9003.tar.gz

tar zxvf DBD-mysql-2.9003.tar.gz
cd DBD-mysql-2.9003
perl Makefile.PL
如果系统提示找不到mysql_config文件,则是由于mysql没有安装全,需要使用Tawie光盘:
首先使用rpm命令查询现在已经安装的mysql包:
# rpm -q mysql
然后安装光盘,装上所有没有安装的其他mysql包:
# mount /dev/cdrom /mnt/cdrom
# cd /mnt/cdrom/tawie/rpms
# ls my*
# rpm -i mysql-devel-4.0.15-3tr.i586.rpm
# rpm -i mysql-bench-4.0.15-3tr.i586.rpm
# rpm -i mysql-client-4.0.15-3tr.i586.rpm
# rpm -i mysql-libs-4.0.15-3tr.i586.rpm
# rpm -i mysql-shared-4.0.15-3tr.i586.rpm
---------
make
如果提示错误:找不到-lssl,是由于openssl没有安装全,
然后安装光盘,装上所有没有安装的其他openssl包:
# mount /dev/cdrom /mnt/cdrom
# cd /mnt/cdrom/tawie/rpms
# ls openssl*
# rpm -i openssl-devel-0.9.7c-1tsl.i586.rpm
# rpm -i openssl-support-0.9.7c-1tsl.i586.rpm
-----------
make test
失败不要紧,再make test一次即可;
make install
---------------------------------------------------------
安装APACHE,支持SSL;
# cd httpd-2.4.xx
# ./configure --prefix=/usr/local/httpd /
    --enable-so    /
    --enable-cgi    /
    --enable-info    /
    --enable-rewrite    /
    --enable-speling    /
    --enable-usertrack    /
    --enable-deflate /
    --enable-ssl    /
    --enable-mime-magic /
    --enable-expires /
    --enable-headers /
    --enable-shared=max /
    --enabel-modules=most /
    --with-ssl=/usr/local/ssl /
    --with-mpm=prefork
   
# make
# make install

安装后,需要替换原来的httpd文件:
# cd /usr/local/httpd/bin
# cp httpd /usr/sbin
# chkconfig --level 2345 httpd on
# httpd -v    //查看默认的httpd的版本,应该是2.0.48;
# service httpd start

安装完成后,修改httpd.conf文件,加入
include /usr/local/httpd/conf/ssl.conf
并将server.crt、server.key拷贝到目录下:
# cd /usr/local/httpd/conf
# mkdir ssl.crt
# mkdir ssl.key
# cp server.crt ssl.crt
# cp server.key ssl.key
使用HTTPS连接,测试ssl是否成功。
------------------------------------------------------------
安装MOD-PERL;
# tar zxvf mod_perl_2.x.xx.tar.gz
# cd modperl_1.99.x
# perl Makefile.PL MP_INST_APACHE2=1 MP_APXS=/usr/local/httpd/bin/apxs
# make
# make test
# make install

安装mod_perl以后,需要修改httpd.conf文件:
# cd /usr/local/httpd/conf
# vi httpd.conf
加入
LoadModule perl_module  modules/mod_perl.so
PerlModule Apache2
PerlRequire "/usr/local/httpd/perl/startup.pl"
PerlOptions +GlobalRequest

详见httpd.conf配置文件。
-------------------------------------------------------------
配置APACHE2
将httpd.conf,startup.pl,ssl.conf拷贝到相应位置,替换原有文件:
# cd /home/ftp/pub
# cp httpd.conf /usr/local/httpd/conf    //替换原有httpd.conf
# cd /usr/local/httpd
# mkdir perl
# cd /home/ftp/pub
# cp startup.pl /usr/local/httpd/perl
# cd /usr/local/httpd/conf
# vi httpd.conf       //注释掉最后一行# include /srv/ca/apache.conf
# cd /usr/local/httpd/cgi-bin
# chmod 755 test-cgi  //更改脚本权限;
# chmod 755 printenv  //更改脚本权限;
# service httpd restart

然后,可以在浏览器中测试apache:
http://132.147.19.69/
http://132.147.19.69/cgi-bin/test-cgi
http://132.147.19.69/cgi-bin/printenv

想要查看Apache的错误调试,查看error_log 文件:
# cd /usr/local/httpd/logs
# cat error_log
# cat >error_log   //清空文件;
按Ctrl_D键


------------------------------------------------------------------------------
安装OPENCA;

准备数据库openca:
# mysqladmin password mysqladmin       //设置口令;
# mysqladmin -pmysqladmin create openca   //建立openca数据库;
# mysql -pmysqladmin  //登录mysql管理台;
mysql> grant all privileges on openca.* to openca@localhost identified by "mysqlopencapasswd"; //设置openca 库;
mysql> exit;    //退出;

Download openca-software from ftp://ftp.openca.org/pub/openca/v0.9/
on both computers ra and ca:
create dir for the web server files:
# mkdir /srv/ca    //建立目录;

 In the directory perhaps /home/openca:
# tar xzf openca-0.9.1.tar.gz
# cd openca-0.9.1


CONFIGURE THE software
---------------------------------

# ./configure --prefix=/srv/ca /
  --with-web-host=ca.intern.results-hannover.de /   //改成: --with-web-host=132.147.19.69
  --with-httpd-host=ca.intern.results-hannover.de /  //改成: --with-httpd-host=132.147.19.69
  --with-httpd-user=wwwrun /  //改成:--with-httpd-user=nobody
  --with-httpd-group=nogroup /  //改成:--with-httpd-group=nobody
  --with-dist-user=wallus /  //改成:--with-dist-user=wallus
  --with-dist-group=openca /  //改成:--with-dist-group=openca
  --with-ca-organization=security /  //改成:--with-ca-organization=wellhope
  --with-ca-locality=Hannover /  //改成:--with-ca-locality=ShenZhen
  --with-ca-country=DE /  //改成:--with-ca-country=CN
  --with-service-mail-account=wallus@results-hannover.de / //改成:--with-service-mail-account=lijf@wellhopegroup.com
  --with-openssl-prefix=/usr/local/ssl /    //改成:--with-openssl-prefix=/usr/local/ssl
  --with-sendmail="/usr/sbin/sendmail -t"/  //改成:--with-sendmail="/usr/sbin/sendmail -t"
  --with-hierarchy-level=ca/  //改成:--with-hierarchy-level=ca
  --enable-dbi/   //改成:--enable-dbi
  --with-db-type=mysql / //改成: --with-db-type=mysql
  --with-db-name=openca /  //改成:--with-db-name=openca
  --with-db-host=localhost /  //改成:--with-db-host=localhost
  --with-db-port=3306 /  //改成:--with-db-port=3306
  --with-db-user=openca /  //改成:--with-db-user=openca
  --with-db-passwd=mysqlopencapasswd/ //改成:--with-db-passwd=mysqlopencapasswd
  --with-ldap-host=ra.results-security.de / //改成:--with-ldap-host=132.147.19.69
  --with-ldap-root="cn=Manager,ou=security,o=results-hannover,c=de"/ //改成:--with-ldap-root="cn=Manager,ou=wellhope,o=ShenZhen,c=cn"
  --with-ldap-root-pwd=ldappasswd //改成: --with-ldap-root-pwd=ldappasswd


Compile and Install CA
-------------------------------
# make ca

# make install-ca


CONFIGURATION of Revocation URL
--------------------------------
Please edit in
   OpenCA/etc/openssl/ca-openssl.cnf
the lines into the correct, from internet accessable URL:
# CRLs
crlDistributionPoints   = URI:https://ra.results-security.de/pub/crl/cacrl.crl
nsCaRevocationUrl       = https://ra.results-security.de/pub/crl/cacrl.crl
nsRevocationUrl         = https://ra.results-security.de/pub/crl/cacrl.crl

The same for  OpenCA/etc/openssl/openssl.cnf and OpenCA/etc/openssl/ra-openssl.cnf
May be it is possible to set this with configure.

配置apache.conf,httpd.conf:
# cd /home/ftp/pub
# cp apache.conf /srv/ca
# chown nobody:nobody /srv/ca/apache.conf
# cd /
# chmod 755 srv -R

# cd /usr/local/httpd/conf
# vi httpd.conf //去掉最后一行的注释符:include /srv/ca/apache.conf
# service httpd restart

故障排除:
--------------------------
1、如果出错,查看/usr/local/httpd/logs/error_log 文件,如果提示can't locate xxx,如果xxx位于相应目录,则是因为缺乏相应权限,
可以修改其权限,包括其上级目录的权限,调试时可以赋予最大权限,即777给其上级目录。

原创粉丝点击