linux openssh升级

本文详细介绍了如何在Linux环境下升级OpenSSH至7.9版本,包括安装依赖、卸载旧版本、配置及安装新版本,并允许root远程登录。同时,文中还提供了禁用Telnet服务的步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一.先安装telnet服务

a、以防卸载openssh后连接不到服务器

yum install telnet-server
yum install telnet
yum install -y telnet-server
yum install -y xinetd 
systemctl enable xinetd.service
systemctl enable telnet.socket
systemctl start telnet.socket
systemctl start xinetd

b、默认情况下,系统是不允许root用户telnet远程登录的。如果要使用root用户直接登录,需设置如下内容:

echo  'pts/0'  >>/etc/securetty
echo 'pts/1' >>/etc/securetty

systemctl restart xinetd.service

c、测试

[root@localhost ~]#telnet

二.升级开始:(注意 : 关闭SELinux)

先把openssh-7.9p1.tar.gz传到服务器上 , 在进行升级的一系列操作.

1.yum安装依赖
yum install -y gcc openssl openssl-devel pam-devel rpm-build pam-devel

2.卸载openssh

[root@localhost src]# rpm -qa | grep openssh
[root@localhost src]# rpm -e `rpm -qa | grep openssh` --nodeps
[root@localhost src]# rpm -qa | grep openssh

3.安装openssh7.9
(参考,包在这里下载 http://www.linuxfromscratch.org/blfs/view/svn/postlfs/openssh.html )
install -v -m700 -d /var/lib/sshd && chown -v root:sys /var/lib/sshd && groupadd -g 50 sshd && useradd -c 'sshd PrivSep' -d /var/lib/sshd -g sshd -s /bin/false -u 50 sshd

[root@localhost src]# tar -zxvf openssh-7.9p1.tar.gz 
[root@localhost src]# cd openssh-7.9p1

 

[root@localhost src]# ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords --with-tcp-wrappers
[root@localhost openssh-7.9p1]# chmod 600 /etc/ssh/ssh_host_rsa_key
[root@localhost openssh-7.9p1]# chmod 600 /etc/ssh/ssh_host_ecdsa_key
[root@localhost openssh-7.9p1]# chmod 600 /etc/ssh/ssh_host_ed25519_key
[root@localhost src]#  make && make install

4.执行如下命令
install -v -m755 contrib/ssh-copy-id /usr/bin && install -v -m644 contrib/ssh-copy-id.1 /usr/share/man/man1 && install -v -m755 -d /usr/share/doc/openssh-7.9p1 && install -v -m644 INSTALL LICENCE OVERVIEW README* /usr/share/doc/openssh-7.9p1

[root@localhost openssh-7.9p1]# ssh -V
OpenSSH_7.9p1, OpenSSL 1.0.2k-fips  26 Jan 2017

5.允许root远程登录 , 开机自启

[root@localhost openssh-7.9p1]# echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
[root@localhost openssh-7.9p1]# cp -a contrib/redhat/sshd.init /etc/init.d/sshd
[root@localhost openssh-7.9p1]# chkconfig --add sshd
[root@localhost openssh-7.9p1]# chkconfig sshd on
[root@localhost openssh-7.9p1]# service sshd start
Starting sshd (via systemctl):                             [  OK  ]
[root@localhost openssh-7.9p1]# service sshd restart
Restarting sshd (via systemctl):                           [  OK  ]
[root@localhost openssh-7.9p1]# chkconfig --list sshd

三.把telnet关掉

[root@localhost openssh-7.9p1]# rpm -qa telnet-server
telnet-server-0.17-64.el7.x86_64
[root@localhost openssh-7.9p1]# systemctl stop telnet.socket 
[root@localhost openssh-7.9p1]# systemctl stop xinetd
[root@localhost openssh-7.9p1]# systemctl disable xinetd.service   
Removed symlink /etc/systemd/system/multi-user.target.wants/xinetd.service.
[root@localhost openssh-7.9p1]# systemctl disable telnet.socket
Removed symlink /etc/systemd/system/sockets.target.wants/telnet.socket.
[root@RHEL5 ~]# rpm -qa | grep telnet
telnet-0.17-38.el5
telnet-server-0.17-38.el5
[root@RHEL5 ~]# rpm -e telnet-0.17-38.el5 # -e参数表示删除rpm包
[root@RHEL5 ~]# rpm -e telnet-server-0.17-38.el5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值