OPEN SSH8.6升级记录

注意事项
1.防止升级过程出现故障,先配置好telnet服务,确保出现故障能远程过去;
2.如果服务器设置过免密登录,升级完后密钥得重新生成;
3.如果是虚拟机升级,打个快照是最好的。

通过yum安装各种依赖包
配置telnet需要安装的服务
yum -y install xinetd
yum -y install telnet-server
yum -y install telnet
gcc编译器及需要用到的依赖
yum -y install gcc
yum -y install perl
yum -y install pam-devel
yum install perl-Test-Harness
yum install perl-Test-Simple

升级zlib版本
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=/usr
make
make install

升级openssh
1.备份当前openssh
mv /etc/ssh /etc/ssh.old
2.卸载当前openssh
rpm -qa|grep openssh
rpm -qa|grep openssh|xargs -i rpm -e --nodeps {}

yum -y install pam-devel
3.openssh安装前环境配置
install -v -m700 -d /var/lib/sshd
chown -v root:sys /var/lib/sshd
4.开始安装
tar -xvf openssh-8.6p1.tar #解压安装包#
cd openssh-8.6p1
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-zlib --with-openssl-includes=/usr --with-privsep-path=/var/lib/sshd
make
make install


重启sshd服务失败,需要执行以下步骤,reload不会失败,但是后期执行restart会失败
第一种解决办法:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
设置开机启动 这里确保service 和systemctl都设置开机启动
cp -a contrib/redhat/sshd.init /etc/init.d/sshd
cp -a contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
chmod +x /etc/init.d/sshd
chkconfig --add sshd
systemctl enable sshd
mv /usr/lib/systemd/system/sshd.service /opt/
mv /usr/lib/systemd/system/sshd.socket /opt/
chkconfig sshd on

setenforce 0

第二种解决方法(在编译升级前修改相关配置文件)
cd openssh-8.4p1
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-tcp-wrappers
在源码openssh-8.4p1目录下,找sshd.c这个主函数文件,找到调用server_accept_loop 这个函数的行,注意这个函数的定义也在这个文件,不要找错了!前加一行代码,效果如下:
/* Signal systemd that we are ready to accept connections /
sd_notify(0, “READY=1”);
/ Accept a connection and return in a forked child */
server_accept_loop(&sock_in, &sock_out,&newsock, config_s);
相应的,在源文件开头几行添加引用头文件:
#include <systemd/sd-daemon.h> (此处#号也要复制进去)
由于默认的依赖中,不包含sd_notify 这个函数,所以还需要安装依赖的包
yum install systemd-devel
apt-get install systemd-devel
修改Makefile,找到变量 LIBS,修改如下:
LIBS=-lcrypto -ldl -lutil -lz -lcrypt -lresolv -lsystemd
然后执行make & make install
最后重启验证
systemctl restart sshd
ps -ef | grep sshd
netstat -ltnp | grep 22
telnet 127.0.0.1 22
ssh -V
————————————————
版权声明:本文为优快云博主「༺小开心༻」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/weixin_45529004/article/details/107487645

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值