centos 7.6 升级openssl_1.1.1j和openssh_8.6p1

centos 7.6 升级openssl_1.1.1j和openssh_8.6p1

1、安装介质

升级openssh需要以下依赖包

pam-devel、gcc、 zlib-devel、keyutils、、libcom、libsepol、pkg、libselinux、krb5、openssl-devel
通过配置yum源安装,或者本地rpm安装

openssl下载链接:
https://www.openssl.org/source/old/1.1.1/
openssh下载链接
http://openbsd.hk/pub/OpenBSD/OpenSSH/portable

2、安装telnet

安装telnet及ftp,防止出现问题无法远程和传输的问题。

telnet 安装

1、root登录,可以先检查是否安装了包:rpm -q telnet-server
2、安装超级服务;
rpm -ivh xinetd-2.3.14-38.el6.x86_64.rpm
3、运行命令:
rpm -ivh telnet-0.17-47.el6_3.1.x86_64.rpm
rpm -ivh telnet-server-0.17-47.el6_3.1.x86_64.rpm
4、
vi /etc/xinetd.d/telnet 
disble=no
vi /etc/pam.d/login
注销该行
#account    required     pam_nologin.so
5、移除securetty文件
mv /etc/securetty /etc/securetty.bak
6、启动服务:
service  xinetd restart

FTP 安装

1、root登录,检查是否安装:rpm -q vsftpd
2、安装服务:
rpm -ivh vsftpd-2.2.2-11.el6.x86_64.rpm
3、启动服务:
service vsftpd start

安装OpenSSL


1、解压下载好的安装包。
tar -zxvf openssl-1.1.1c.tar.gz
2、切换到目标目录下。
cd /usr/local/openssl/openssl-1.1.1j
3、设定Openssl 安装,( --prefix )参数为欲安装之目录,也就是安装后的档案会出现在该目录下,执行命令:
 ./config --prefix=/usr/local/openssl
4、执行命令
./config -t
5、执行make,编译Openssl
make && make install
6、切换目录
cd /usr/local
7、设置依赖文件目录
ldd /usr/local/openssl/bin/openssl
8、查看OpenSSL的设置目录
which openssl
9、查看系统的OpenSSL版本信息
openssl version -a
10、备份原系统的文件
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
11、设置新的配置
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
ldconfig -v


解决openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory错误问题,这是由于openssl库的位置不正确造成的,解决办法如下:

ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
 
ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
 

安装Openssh

解压
# tar -xf openssh-8.6p1.tar.gz
# cd openssh-8.6p1
 
编译
# ./configure   --prefix=/usr   --sysconfdir=/etc/ssh   --with-md5-passwords   --with-pam   --with-tcp-wrappers   --with-ssl-dir=/usr/local/openssl --without-hardening
 
编译安装
# make && make install
 
修改配置文件
(1)备份sshd文件,重命名为sshd.bak
cp /etc/init.d/sshd  /etc/init.d/sshd.bak
(2)复制配置文件、赋权、添加到开机启动项 (/ ssh/openssh-7.4p1为解压目录)
cd contrib/redhat
cp sshd.init  /etc/init.d/sshd

chmod u+x /etc/init.d/sshd
chkconfig --add sshd
chkconfig sshd on

备份原文件
cp /etc/ssh/ssh_config   /etc/ssh/ssh_config.bak
cp /etc/ssh/sshd_config  /etc/ssh/sshd_config.bak
 

查看安装后openssh版本
ssh -V

设置允许root用户登录(openssh升级后,root默认被禁用)
打开
vi /etc/ssh/sshd_config
文件,将PermitRootLogin设置为yes

	
重启SSH
service sshd restart

如果ssh启动时报错:
(Starting sshd:/etc/ssh/sshd_config line 81: Unsupported option GSSAPIAuthentication
/etc/ssh/sshd_config line 83: Unsupported option GSSAPICleanupCredentials)
将sshd_congfig 文件中的GSSAPIAuthentication、GSSAPICleanupCredentials两行用#号注释掉即可。

停止telnet和ftp服务

停止Telnet服务
1.修改配置文件
将vi /etc/xinetd.d/telnet文件中的disable= no修改为disable= yes
 
2.设置telnet开机不启动
chkconfig  xinetd off
 
3.关闭telnet服务
/etc/init.d/xinetd stop
mv /etc/securetty.bak /etc/securetty
停止FTP服务
service vsftpd stop
停止服务

其他问题

1、低版本ssh无法连接问题

ssh8.6p1

服务器发送了一个意外的数据包

KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1

1、要求客户升级SecureCRT版本至6.5或7.x,或更换最新版的Xshell、Putty等工具,即可正常登录

2、修改ssh配置,添加对原加密算法的支持:

在/etc/ssh/sshd_config配置文件中添加以下三行,并重启sshd服务;

Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc

MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96

KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,curve25519-sha256@libssh.org

2、centos7 sshd服务状态为activating(start)

现象:

如图,
centos7升级ssh7.4到8.1版本后,ssh连接不稳定,时断时续,systemctl status sshd查看服务状态为activating(start),查看/var/log/message里不断提示sshd.service holdoff time over,scheduling restart

原因:
/usr/lib/systemd/system/sshd.service 与systemd不兼容

处理办法:
mkdir /etc/ssh_bak
mv /usr/lib/systemd/system/sshd.service /etc/ssh_bak/
systemctl daemon-reload

sshd -t
systemctl restart sshd
systemctl status sshd

重启前看下:
sshd -t 检查下配置有没有问题

   /var/log/message里sshd有没有继续报错,ssh -v  root@ip检查下能否正常连接

以上正常后systemctl restart sshd

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值