debian系统升级openssh
复制代码
1
2
3
4最近护网行动开始了,公司的老的服务器开始修补漏洞,今天我修补的漏洞是openssh。 OpenSSH 是 SSH (Secure SHell) 协议的免费开源实现。SSH协议族可以用来进行远程控制, 或在计算机之间传送文件。而实现此功能的传统方式,如telnet(终端仿真协议)、 rcp ftp、 rlogin、rsh都是极为不安全的,并且会使用明文传送密码。OpenSSH提供了服务端后台程序和客户端工具,用来加密远程控制和文件传输过程中的数据,并由此来代替原来的类似服务。
复制代码
1
2
3
4
5
6
7
8
9#首先我们看下自己服务器的ssh版本,现在最新版本是8.6 root@hecs-x-medium-2-linux-20210317100343:/opt# ssh -V OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019 root@hecs-x-medium-2-linux-20210317100343:/opt# vim updatessh.sh #将下面内容依次执行也可以,或者复制在脚本中执行,切记脚本执行报错就不要执行第二次,脚本报错就开始排查脚本执行到哪步报错,然后解决报错的问题依次执行脚本下面内容即可
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46##### openssh升级到8.6命令 # 安装依赖 apt-get install -y aptitude aptitude install -f libpam0g-dev libselinux1-dev apt-get install -y libssl-dev zlib1g-dev # 备份ssh配置 cp -rf /etc/ssh /etc/ssh.bak # 设置文件权限 chmod 600 /etc/ssh/ssh_host_rsa_key chmod 600 /etc/ssh/ssh_host_ecdsa_key chmod 600 /etc/ssh/ssh_host_ed25519_key # 配置sshd配置 sed -i 's/^#PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config sed -i 's/^GSSAPIAuthentication/#&/' /etc/ssh/sshd_config sed -i 's/^GSSAPICleanupCredentials/#&/' /etc/ssh/sshd_config sed -i 's/^UsePAM/#&/' /etc/ssh/sshd_config # 配置service, 取消notify sed -i 's/^Type/#&/' /lib/systemd/system/ssh.service # 下载包 wget https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.6p1.tar.gz tar zxf openssh-8.6p1.tar.gz # 编译安装 cd openssh-8.6p1 ./configure --prefix=/usr --with-privsep-path=/var/empty/sshd/ --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl/ --with-default-path=/usr/local/bin:/bin:/usr/bin --with-superuser-path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin --with-pam --with-selinux --disable-strip --with-md5-passwords make make install # 重启服务 systemctl daemon-reload systemctl restart sshd # 现在版本 ssh -V
复制代码
1
2
3
4
5
6
7root@hecs-x-medium-2-linux-20210317100343:/opt# bash updatessh.sh #执行脚本最后成功的标志是ssh变成8.5,因为脚本最后的ssh -V就是返回当前ssh的版本号,我记得我上次离职的时候公司正在升级8.5的版本,我今天升级的8.1,明天过去给升级成8.5,今天在我的服务器已经测试了。 root@hecs-x-medium-2-linux-20210317100343:/opt# ssh -V OpenSSH_8.6p1, OpenSSL 1.1.1d 10 Sep 2019
复制代码
1
2# 以下是我执行中报错的解决方式
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99configure: error: *** zlib.h missing - please install first or check config.log *** make: *** No targets specified and no makefile found. Stop. make: *** No rule to make target 'install'. Stop. 报错1:configure: error: *** zlib.h missing - please install first or check config.log *** 解决方式: apt install zlib1g-dev -y 报错2:configure: error: *** working libcrypto not found, check config.log 解决方式: apt install openssl apt install libssl-dev 报错3: apt-get install aptitude aptitude install libssl-dev #升级中出现的错误解决 ##### openssh升级到8.1命令 # 安装依赖 apt-get install -y aptitude aptitude install -f libpam0g-dev libselinux1-dev apt-get install -y libssl-dev zlib1g-dev # 备份ssh配置 cp -rf /etc/ssh /etc/ssh.bak1 # 设置文件权限 chmod 600 /etc/ssh/ssh_host_rsa_key chmod 600 /etc/ssh/ssh_host_ecdsa_key chmod 600 /etc/ssh/ssh_host_ed25519_key # 配置sshd配置 sed -i 's/^#PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config sed -i 's/^GSSAPIAuthentication/#&/' /etc/ssh/sshd_config sed -i 's/^GSSAPICleanupCredentials/#&/' /etc/ssh/sshd_config sed -i 's/^UsePAM/#&/' /etc/ssh/sshd_config # 配置service, 取消notify sed -i 's/^Type/#&/' /lib/systemd/system/ssh.service # 下载包 wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.6p1.tar.gz tar zxf openssh-8.6p1.tar.gz # 编译安装 openssh cd openssh-8.6p1 ./configure --prefix=/usr --with-privsep-path=/var/empty/sshd/ --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/ssl/ --with-default-path=/usr/local/bin:/bin:/usr/bin --with-superuser-path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin --with-pam --with-selinux --disable-strip --with-md5-passwords make make install # 编译openssh 报错 C compiler cannot create executables apt --fix-broken install apt-get install gcc # Yes, I say ! # dpkg 修复 apt-get download libc-bin dpkg -x libc-bin*.deb unpackdir/ cp unpackdir/sbin/ldconfig /sbin/ apt-get install --reinstall libc-bin apt-get -f install apt-get install lib32z1-dev # 报错dpkg: warning: 'ldconfig' not found in PATH or not executable 编译openssl git clone git://git.openssl.org/openssl.git cd openssl ./config --shared make make install # 编译openssh报错 configure: error: OpenSSL version header not found ln -s /usr/local/lib/libssl.so.3 /usr/lib/libssl.so.3 ln -s /usr/local/lib/libcrypto.so.3 /usr/lib/libcrypto.so.3 # 编译openssh报错 configure: error: PAM headers not found apt-get install libpam0g-dev # 编译openssh报错 configure: error: SELinux support requires selinux.h header # ssh服务消失 apt-get update apt-get install ssh # 选择默认即可 # 最后再重新执行 make install # 重启服务 systemctl daemon-reload systemctl restart sshd # 现在版本 ssh -V
最后
以上就是踏实冷风最近收集整理的关于debian系统升级ssh的全部内容,更多相关debian系统升级ssh内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复