最近有空复习了一下Linux,在虚拟机上安装了个CentOS6.5,顺便升级一下系统自带的openssh,任何系统操作都有风险,正式环境请做好备份工作。废话少说,直接贴代码。
1、准备工作,相应的包自己到官方下载,另外需要下载依赖包openssl以及zlib包。
openssh下载地址:http://www.openssh.com/portable.html#http
openssl下载地址:http://www.openssl.org/source/
zlib下载地址:http://zlib.net/zlib-1.2.8.tar.gz
2、卸载系统自带的openssh,卸载之前先停止sshd服务,再用rpm删除,同时清除系统/etc/ssh目录
[root@CentOStmp]#servicesshdstop
Stoppingsshd:[OK]
[root@CentOStmp]#rpm-qaopenssh
openssh-5.3p1-94.el6.x86_64
[root@CentOStmp]#rpm-eopenssh-server
[root@CentOStmp]#rpm-eopenssh-clients
[root@CentOStmp]#rpm-eopenssh-askpass
[root@CentOStmp]#rpm-eopenssh
[root@CentOStmp]#rm-rf/etc/ssh
3、安装zlib
[root@CentOStmp]#tar-xvfzlib-1.2.8.tar.gz
[root@CentOStmp]#cdzlib-1.2.8
[root@CentOSzlib-1.2.8]#./configure--prefix=/usr/local/zlib&&make&&makeinstall
4、安装openssl
[root@CentOStmp]#tar-xvfopenssl-1.0.1i.tar.gz
[root@CentOStmp]#cdopenssl-1.0.1i
[root@CentOSopenssl-1.0.1i]#./config--prefix=/usr/local/openssl&&make&&makeinstall
5、安装openssh
[root@CentOStmp]#tar-xvfopenssh-6.6p1.tar.gz
[root@CentOStmp]#cdopenssh-6.6p1
[root@CentOSopenssh-6.6p1]#./configure--prefix=/usr/local/openssh--sysconfdir=/etc/ssh--with-ssl-dir=/usr/local/openssl--with-zlib=/usr/local/zlib--with-md5-passwords--without-hardening&&make&&makeinstall
[root@CentOSopenssh-6.6p1]#cpcontrib/redhat/sshd.init/etc/init.d/sshd
[root@CentOSopenssh-6.6p1]#chmod+x/etc/init.d/sshd
[root@CentOSopenssh-6.6p1]#vi/etc/init.d/sshd
修改对应指令的安装目录
=============================
25行SSHD=/usr/sbin/sshd为SSHD=/usr/local/openssh/sbin/sshd
41行/usr/bin/ssh-keygen-A为/usr/local/openssh/bin/ssh-keygen-A
=============================
保存退出
7、加入到系统服务
[root@CentOSopenssh-6.6p1]#chkconfig--addsshd
[root@CentOSopenssh-6.6p1]#servicesshdstart
8、编译中遇到的错误,参考博文http://zjwsk.blog.163.com/blog/static/598306132014313112351/,感谢博主的分享
configure:error:***Can'tfindrecentOpenSSLlibcrypto(seeconfig.logfordetails)***