Openssh更新步骤
一、准备文件
安装源文件放在/usr/local/src目录下 zlib-1.2.7.tar.gz
openssl-1.0.1c.tar.gz
openssh-5.5p1.tar.gz
zlib和openssl安装在/usr/local目录下
二、关闭并卸载自带的Openssh
1、开启Telnet远程管理
查询是否安装telnet
# rpm -qa | grep
telnettelnet-server-0.17-31.EL4.5 telnet-0.17-31.EL4.5
如果没安装,请安装以上两部分内容,加载ISO文件(mount -o loop abc.iso /media/iso),访问SERVER目录下,执行:
# rpm –ivh telnettelnet-server-0.17-31.EL4.5
warning: telnet-server-0.17-39.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:telnet-server ########################################### [100%]
# rpm –ivh telnet-0.17-31.EL4.5
warning: telnet-0.17-39.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
package telnet-0.17-39.el5.i386 is already installed # vi /etc/xinetd.d/telnet # default: on
# description: The telnet server serves telnet sessions; it uses \\
# unencrypted username/password pairs for authentication. service telnet
{
disable }
flags = REUSE socket_type = stream wait = no user = root
server = /usr/sbin/in.telnetd log_on_failure += USERID = no
编辑红色部分,将yes改为no,并保存退出。
# /etc/init.d/xinetd restart
检查开启是否成功:
#netstat -tnlp | grep :23
tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN 3177/xinetd
开启成功。
telnet不能使用root用户登陆,新建普通用户并创建密码
#useradd sshupdate #passwd sshupdate
Changing password for user sshupdate. New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
telnet远程访问,并切换root
# telnet -l sshupdate 10.10.10.5 Trying 10.10.10.5...
Connected to 10.10.10.5. Escape character is '^]'. Password:
Last login: Sat Jun 30 11:40:52 from 10.10.10.4 [sshupdate@localhost ~]$ su 口令:
[root@localhost sshupdate]#
2、停止并卸载Openssh
停止OpenSSH服务
#/sbin/service sshd stop
查询并卸载openssh
#/sbin/service sshd stop # rpm -qa | grep opensshopenssh openssh-askpass openssh-clients
openssh-server openssh-askpass
#rpm -e openssh --nodeps
#rpm -e openssh-clients --nodeps #rpm -e openssh-askpass--nodeps #rpm -e openssh-server --nodeps #rpm -e openssh-askpass--nodeps
三、安装库文件和Openssh
1、安装zlib-1.2.7
#tar -zxvf zlib-1.2.7.tar.gz #cd zlib-1.2.7
#./configure --prefix=/usr/local/zlib-1.2.7 -share #make #make test #make install
#vi /etc/ld.so.conf 配置库文件搜索路径 include ld.so.conf.d/*.conf ##add start
/usr/local/zlib-1.2.7/lib ##add end
#/sbin/ldconfig -v 刷新缓存文件/etc/ld.so.cache #ln -s /usr/local/zlib-1.2.7 /usr/local/zlib
2、安装openssl(可以略过)
#cd /usr/local/src
#tar zxvf openssl-1.0.1c.tar.gz #cd openssl-1.0.1c
#./config shared zlib-dynamic --prefix=/usr/local/openssl-1.0.1c
--with-zlib-lib=/usr/local/zlib-1.2.7/lib --with-zlib-include=/usr/local/zlib-1.2.7/include #make
#make test (这一步是进行 SSL 加密协议的完整测试,如果出现错误就要一定先找出原因,否则一味继续可能导致 SSH 不能使用!) #make install
#vi /etc/ld.so.conf 配置库文件搜索路径
############################################
## add below line to ld.so.conf
/usr/local/ openssl-1.0.1c /lib 位OS 没有生成lib目录,是lib目录############################################ #/sbin/ldconfig -v 刷新缓存文件/etc/ld.so.cache #ln -s /usr/local/openssl-1.0.1c /usr/local/openssl vi /etc/profile
########################################### (add to end of the file)
PATH=/usr/local/openssl/bin:$PATH export PATH
###########################################
退出,再登录,查看openssl的版本号,以验正是否安装正确
#openssl version -a OpenSSL 1.0.1c
built on: Wed Jul 7 17:08:07 CST 2010platform. linux-x86_options: bn(,)
rc4(1x,char) des(idx,cisc,16,int) idea(int) blowfish(idx)compiler: gcc -fPIC -DOPENSSL_PIC -DZLIB_SHARED -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -m -DL_ENDIAN -DTERMIO -O3 -Wall -DMD32_REG_T=int -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DWHIRLPOOL_ASMOPENSSLDIR: \"/usr/local/openssl-1.0.1c/ssl\"
3、安装OpenSSH
#cd /usr/local/src
# tar zxvf openssh-5.5p1.tar.gz # cd openssh-5.5p1
#./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam
--with-ssl-dir=/usr/local/openssl-1.0.1c --with-md5-passwords --mandir=/usr/share/man --with-zlib=/usr/local/zlib-1.2.7 #make
#make install
将sshd加入启动服务:进入ssh安装解压目录
#cp ./contrib/redhat/sshd.init /etc/init.d/sshd #chmod +x /etc/init.d/sshd #/sbin/chkconfig --add sshd
最后,启动 SSH 服务使修改生效
# /sbin/service sshd start
重启后确认一下当前的 OpenSSH 和 OpenSSL 是否正确:
# ssh -v
OpenSSH_5.5p1, OpenSSL 0.9.8r 8 Feb 2011
如果看到了新的版本号就没问题啦!
4、关闭telnet服务
修改设置文件/etc/xinetd.d/telnet中disable字段改为yes。 启动服务
#/sbin/service xinetd restart