在solaris8下安装vsftp

 

Vsftpd+ssl在solaris8下的安装折磨了我2天,整整2天,差点不眠不休,tmd累死朕了~!(后来的SSL部分受折磨的时间更长)

先说安装过程,下载解压,如果需要ssl,tcp wrapper等的支持(就是这个ssl编译浪费了我一天半,后面会说到),则先编辑builddefs.h这个文件.具体方法README和 README.ssl文档中都有说.记得还要看INSTALL文档。总之源文件下的文档一定要先看一遍。编辑完builddefs.h之后,make,不会报错,再make install也不会报错,但是你需要手动cp一些文件到相应的目录下(具体是哪些INSTALL中有写)。之后修改配置文件,/etc /vsftpd.conf,如果禁止匿名连接的话,一定要显性的标明anonymous=NO,否则缺省配置下,local_user连接也会有问题(可能是没有在系统中添加用户“ftp”的原因)。之后就可以/var/sbin/vsftpd &启动vsftpd了,也可以后面直接写配置文件路径。

但是问题就出在这里,缺省是没有启动ssl的,如果你在配置文件中打开ssl的选项,启动vsftpd时就会告诉你ssl选项is enable ,but not complite in之类的。此时你才发现,我靠,真的没有编译进来呀,丫的居然编译时还一个错都没报。Ok,没办法,重新编译。回到安装路径,make clean先。

 

没编译进来的原因可能是我这台solaris8系统中的 openssl,gcc还有其他一些互相依赖的程序,都是使用freeware的package方式安装的,路径不能定制。可能这和vsftpd默认的 openssl的安装路径不符(编译的时候需要openssl的一些头文件(.h 通常在/include,/usr/include,/usr/local/include以及openssl的安装目录下的/include)和库文件(.o之类的,通常在/lib,/usr/lib,/usr/local/lib,已经openssl的安装目录下的/lib)的支持),因此出现上述情况。于是千查万找开始修改Makefile文件,在CFLAGS行加入

 CFLAGS  =        -I/usr/local/ssl/include -I/usr/include -I/usr/local/include -L/usr/local/ssl/lib -L/usr/local/lib -L/usr/lib -L/lib -O2 -Wall -W -Wshadow #-pedantic -Werror Wconversion

其中-I代表库文件路径,-L表示头文件路径。但实际情况好像是-I起了作用,而-L没有起作用,无论我把-L指向多少个地方都不行,报出如下错误(后来才知道-L不是加在这里的,要加在LINK行中):

ld: fatal: library -lssl: not found
ld: fatal: library -lcrypto: not found
ld: fatal: File processing errors. No output written to vsftpd
collect2: ld returned 1 exit status
make: *** [vsftpd] Error 1

最后exprot LD_LIBRARY_PATH=/usr/local/ssl/lib后才算编译过去。不知道为什么,库文件路径只在这个参数中生效,而不理会-L(现在知道了,因为要写在LINK行嘛…… 浪费我这么长时间!)

好像依赖openssl的编译都需要这个环境变量。可以临时把它写到系统配置文件当中了,不能随用随写。很容易忘记。我就是因为logout后一直没有添加这个变量而浪费了两个小时。

安装路径下有一些文件可以有助于判断问题所在,比如: vsf_findlibs.sh其他的想不起来了-_-!

其中EXAMPLE中有一些配置好的模板,可以适当修改后使用。还有很多文档可看。总之,以大写字母命名的东西尽量看一看吧。

tunables.c好像是预配置文件,修改这个后保存,就不用每次重装的时候再重新配置了。当然你保存安装后的配置文件也行,呵呵。

解决问题的过程中学到一些方法,主要就是grep!拿着出错信息在安装文件中到处grep,慢慢的你就知道有些东西是干吗的了,是否有对应的文档提到这些东西。这方法对于我这种unix超级新手很受用,这要多谢baa兄弟的指引了。

先到这里,赶车回家。明天继续。

=============================偶素日期分割等号阵列================================

编译算是结束了,但没想到SSL才是噩梦的开始,F~*~C~K~丫~!!!

在vsftpd.conf中enable_ssl并指定证书位置rsa_cert_file=后,执行vsftpd,出现提示:500 OOPS: SSL: RNG is not seeded

提示的意思我猜是密钥协商过程需要一个随机数(seed),但是不知道什么原因,这个随机数没有生成。google it~!动用了这颗星球上最强大的搜索引擎,居然只在freshmeat上得到唯一的信息--同样也是提问,没有回答轻微抓狂~~。拆散关键字regoogle,返回结果多数和openssl有关,模糊,无头绪。只知道随机数的生成可能需要/dev/random或/dev/urandom,查找系统,发现没有这两个文件/目录,却又不知如何生成。来自www.stunnel.org的一条消息引人注意:

·         Stunnel 3.8 or earlier fails with a "PRNG not seeded" error message.

Solution Download Stunnel 3.8p1 or later, or apply the patch for this problem available from the stunnel.org patch library
The problem stems from the fact that as of OpenSSL 0.9.5, the underlying SSL libraries require that the cryptographic algorithms have their random number generator seeded with random information. See http://www.openssl.org/support/faq.html#USER1 for the explanation.
All versions from 3.8p1 on have this bug fixed. Prior to that it only affected operating systems without a /dev/urandom device.

转到openssl站点深入追查:

l          Why do I get a "PRNG not seeded" error message? Cryptographic software needs a source of unpredictable data to work correctly. Many open source operating systems provide a "randomness device" (/dev/urandom or /dev/random) that serves this purpose. All OpenSSL versions try to use /dev/urandom by default; starting with version 0.9.7, OpenSSL also tries /dev/random if /dev/urandom is not available. On other systems, applications have to call the RAND_add() or RAND_seed() function with appropriate data before generating keys or performing public key encryption. (These functions initiali
ze the pseudo-random number generator, PRNG.) Some broken applications do not do this. As of version 0.9.5, the OpenSSL functions that need randomness report an error if the random number generator has not been seeded with at least 128 bits of randomness. If this error occurs and is not discussed in the documentation of the application you are using, please contact the author of that application; it is likely that it never worked correctly. OpenSSL 0.9.5 and later make the error visible by refusing to perform potentially insecure encryption.
If you are using Solaris 8, you can add /dev/urandom and /dev/random devices by installing patch 112438 (Sparc) or 112439 (x86), which are available via the Patchfinder at http://sunsolve.sun.com (Solaris 9 includes these devices by default). For /dev/random support for earlier Solaris versions, see Sun’s statement at http://sunsolve.sun.com/pub-cgi/retrieve.pl?doc=fsrdb/27606&zone_32=SUNWski (the SUNWski package is available in patch 105710). On systems without /dev/urandom and /dev/random, it is a good idea to use the Entropy Gathering Demon (EGD); see the RAND_egd() manpage for details. Starting with version 0.9.7, OpenSSL will automatically look for an EGD socket at /var/run/egd-pool, /dev/egd-pool, /etc/egd-pool and /etc/entropy. Most components of the openssl command line utility automatically try to seed the random number generator from a file. The name of the default seeding file is determined as follows: If environment variable RANDFILE is set, then it names the seeding file. Otherwise if environment variable HOME is set, then the seeding file is $HOME/.rnd. If neither RANDFILE nor HOME is set, versions up to OpenSSL 0.9.6 will use file .rnd in the current directory while OpenSSL 0.9.6a uses no default seeding file at all. OpenSSL 0.9.6b and later will behave similarly to 0.9.6a, but will use a default of "C:" for HOME on Windows systems if the environment variable has not been set. If the default seeding file does not exist or is too short, the "PRNG not seeded" error message may occur. The openssl command line utility will write back a new state to the default seeding file (and create this file if necessary) unless there was no sufficient seeding. Pointing $RANDFILE to an Entropy Gathering Daemon socket does not work. Use the "-rand" option of the OpenSSL command line tools instead. The $RANDFILE environment variable and $HOME/.rnd are only used by the OpenSSL command line tools. Applications using the OpenSSL library provide their own configuration options to specify the entropy source, please check out the documentation coming the with application.

 

也就是说,solaris8系统需要打补丁(112438)才会出现/dev/random或/dev/urandom文件。满心欢喜以为打上补丁reboot就会搞定,随后发现上帝再次强奸了我的意愿。

缝上了补丁的系统仍然没有那两个该死的文件强忍悲痛按照下面的说法继续作出了$home/.rnd文件,输入了至少三行的随机数字,并且在.profile中添加了指向$home/.rnd的 RANDFIEL变量。relogin,现象依旧。这咋办?搜索openssl rnd rng prng random solaris ……能搜的都搜了,man openssl ,grep openssl目录和vsftpd目录..能找的都找了,还是没搞定。顺便骂一下vsftpd的网站,吝啬得要死,连个鸟论坛都没有……I hate newsgroup,I hate maillist~!!!   

老夫黔驴技穷了.

 

生活总是在不经意间给你惊喜,来自CU的一篇有关OpenSSH的文章总算让我看到了曙光!

Solaris8上安装SSH
安装步骤
初始步:得到Solaris 8random补丁
PRNG is not seeded
这个问题所困扰 下面是我的解决办法
首先要保证openssh所要求的包你都安装了 
1
sunpatch 112438-01 
其实这个patch安装了有时也没有用 打这个patch的目的是因为8默认没有一个随机数设备
安装这个patch就是为解决这个问题 但从实际使用情况来看,没有什么用 所以建议不要安装。 

2。安装一个第3方的软件 ANDIrand-0.7-5.8-sparc-1.pkg
安装了这个软件之后,会在/dev/目录下生成2个随机数设备 
random urandom
安装之后不用重起 
这时你在起 openssh 就会正常了 

这个软件的下载地址
for 2.6
http://www.cosy.sbg.ac.at/~andi/SUNrand/pkg/ANDIrand-0.7-5.6-sparc-1.pkg

for 8
http://www.cosy.sbg.ac.at/~andi/SUNrand/pkg/ANDIrand-0.7-5.8-sparc-1.pkg 

 

下载安装

## Installing part 1 of 1.
/etc/init.d/random
/usr/kernel/drv/random
/usr/kernel/drv/random.conf
[ verifying class <none> ]
/etc/rc0.d/K50random <linked pathname>
/etc/rc2.d/S60random <linked pathname>
Modifying /etc/devlink.tab
[ verifying class <sed> ]
/usr/kernel/drv/sparcv9/random
[ verifying class <km64> ]
## Executing postinstall script.
Initializing random number generator...
driver not loaded!
 
Installation of <ANDIrand> was successful.
bash-2.03# 

 

居然driver not loaded!!

查看/dev/下既没有ramdon,也没有uramdon,

遂从/usr/kernel/drv/random link 过来: ln s /usr/kernel/drv/random /dev/urandom

执行/etc/rc2.d/S60random start,还报错。

再cat /etc/rc2.d/S60random,发现seed指向:random_seed=/var/tmp/random-seed

又vi /var/tmp/random-seed,并输入三行随机数字。

最后执行/etc/rc2.d/S60random start        未报错,成功启动。

最后时刻来到~~颤抖着指头敲入vsftpd……噢麦高,再也没出现the fucking“500 OOPS: SSL: RNG is not seeded”!!!!!!!!!祭起flashFXP测试~~嘿嘿嘿嘿~~仰天长啸~~~~~~~

 

过程说来简单,但其间走了无数弯路,经历了无数大喜大悲这两天心脏已经暂不随国家利率跳动了唉。感谢支持我的家人,感谢导师,感谢同事,感谢所有给我帮助的兄弟姐妹,感谢主办方,感谢CCTV,感谢MTV……

严重感谢CU的songyupo写的那篇关于OpenSSH的文章,小弟这里含泪遥拜了~~

 

 

总算告一段落了,其他参数的微调就按照手册去做就可以了。还有一个问题就是想让用户有upload resume的权限,但是却不可以删除文件,不知道vsftpd能不能实现。

还有就是磁盘配额,定时删除,限制访问时间等功能,慢慢研究吧。如果来得及,再加入tcp wrapper。

 

参考文章:

http://bbs.chinaunix.net/forum/viewtopic.php?t=432491

http://www.openssl.org/support/faq.html#USER1

http://www.chinaunix.net/jh/6/395013.html

http://fanqiang.chinaunix.net/a6/b8/20010421/173933.html

记不住了……

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注