ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ssh7.4升级到9.3p2

ssh7.4升级到9.3p2

原创 Linux操作系统 作者:hellohf123 时间:2023-12-13 11:55:05 1 删除 编辑

1、首先查看当前版本 centos7 默认使用ssh

[root@dbserver ~]# ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
[root@dbserver ~]# sshd -v
unknown option -- v
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017

2、安装依赖包

yum -y install gcc gcc-c++ zlib zlib-devel openssl openssl-devel pam-devel libselinux-devel wget

3、下载

mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/
mv openssh-9.3p2.tar.gz /opt && cd /opt

4、解压安装

[root@dbserver opt]# tar -zxvf openssh-9.3p2.tar.gz
[root@dbserver opt]# cd openssh-9.3p2/

5、备份openssh

mv /etc/ssh /etc/ssh.bak
mkdir /usr/bin/bak
cp -arpf /usr/bin/{cp,sftp,ssh,ssh-add,ssh-agent,ssh-keygen,ssh-keyscan} /usr/bin/bak/
cp -arpf /usr/sbin/sshd /usr/sbin/sshd.bak
cp -arpf /etc/sysconfig/sshd /etc/sysconfig/sshd.bak
cp -arpf /etc/pam.d/sshd /etc/pam.d/sshd.bak


6、执行安装

./configure --with-md5-passwords --with-pam --with-selinux --with-privsep-path=/sshd   --sysconfdir=/etc/ssh
由于启用了PAM则需要安装一个配置文件,该文件在contrib目录下
cp -a contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
#拷贝开机启动脚本
cp -a contrib/redhat/sshd.init /etc/init.d/sshd
chmod +x /etc/init.d/sshd
mv /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/sshd.service.bak
编译成可执行文件
make && make install

7、修改文件权限

chmod 600 /etc/ssh/ssh_host_rsa_key
chmod 600 /etc/ssh/ssh_host_ecdsa_key
chmod 600 /etc/ssh/ssh_host_ed25519_key

8、修改配置

修改配置文件 允许root远程登录
将PermitRootLogin prohibit-password 修改为 PermitRootLogin yes
vim /etc/ssh/sshd_config
PermitRootLogin yes
关闭DNS选项加快访问
PubkeyAuthentication yes
注释下面2个配置
#GSSAPIAuthentication yes
#GSSAPICleanupCredentials no
检查ssh配置 无报错即为正常
#检查是否有配置错误
sshd -t

9、替换新版本openssh文件,一条一条执行,确认

cp -arpf /opt/openssh-9.3p2/scp /usr/bin/
cp -arpf /opt/openssh-9.3p2/sftp /usr/bin/
cp -arpf /opt/openssh-9.3p2/ssh /usr/bin/
cp -arpf /opt/openssh-9.3p2/ssh-add /usr/bin/
cp -arpf /opt/openssh-9.3p2/ssh-agent /usr/bin/
cp -arpf /opt/openssh-9.3p2/ssh-keygen /usr/bin/
cp -arpf /opt/openssh-9.3p2/ssh-keyscan /usr/bin/
cp -arpf /opt/openssh-9.3p2/sshd /usr/sbin/sshd


9、启动服务,验证ssh版本

systemctl daemon-reload
systemctl enable sshd.socket
sshd -t
systemctl restart sshd
systemctl enable sshd
systemctl status sshd


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70004783/viewspace-2999914/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: suse 15 sp6 安装
请登录后发表评论 登录
全部评论

注册时间:2021-08-05

  • 博文量
    78
  • 访问量
    81359