最近有空复习了一下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目录
[[email protected] tmp]# service sshd stop Stopping sshd: [ OK ] [[email protected] tmp]# rpm -qa openssh openssh-5.3p1-94.el6.x86_64 [[email protected] tmp]# rpm -e openssh-server [[email protected] tmp]# rpm -e openssh-clients [[email protected] tmp]# rpm -e openssh-askpass [[email protected] tmp]# rpm -e openssh [[email protected] tmp]# rm -rf /etc/ssh
3、安装zlib
[[email protected] tmp]# tar -xvf zlib-1.2.8.tar.gz [[email protected] tmp]# cd zlib-1.2.8 [[email protected] zlib-1.2.8]# ./configure --prefix=/usr/local/zlib && make && make install
4、安装openssl
[[email protected] tmp]# tar -xvf openssl-1.0.1i.tar.gz [[email protected] tmp]# cd openssl-1.0.1i [[email protected] openssl-1.0.1i]# ./config --prefix=/usr/local/openssl && make && make install
5、安装openssh
[[email protected] tmp]# tar -xvf openssh-6.6p1.tar.gz [[email protected] tmp]# cd openssh-6.6p1 [[email protected] openssh-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 && make install
6、修改配置文件
[[email protected] openssh-6.6p1]# cp contrib/redhat/sshd.init /etc/init.d/sshd [[email protected] openssh-6.6p1]# chmod +x /etc/init.d/sshd [[email protected] openssh-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、加入到系统服务
[[email protected] openssh-6.6p1]# chkconfig --add sshd [[email protected] openssh-6.6p1]# service sshd start
8、编译中遇到的错误,参考博文http://zjwsk.blog.163.com/blog/static/598306132014313112351/,感谢博主的分享
configure: error: *** Can‘t find recent OpenSSL libcrypto (see config.log for details) ***
时间: 2024-10-17 11:24:43