美文网首页
centos8.4下编译openssh9.7

centos8.4下编译openssh9.7

作者: 明翼 | 来源:发表于2024-06-12 13:58 被阅读0次

一 准备

在CentOS-AppStream.repo、CentOS-AppStream.repo、CentOS-Extras.repo这些配置文件添加阿里云yum源路径  baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/



sudo yum -y groupinstall 'Development Tools'
yum install openssl
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.7p1.tar.gz
tar xvf *.gz
cd openssh*
./configure

报错1:
checking if getpgrp accepts zero args... yes
checking for openssl... /bin/openssl
configure: error: *** working libcrypto not found, check config.log

解决办法1:
yum install -y openssl-devel

./configure
make && make install
cp ./contrib/redhat/openssh.spec  ./

[root@localhost openssh-9.7p1]#   sed -i -e "s/%define no_x11_askpass 0/%define no_x11_askpass 1/g" openssh.spec
[root@localhost openssh-9.7p1]#   sed -i -e "s/%define no_gnome_askpass 0/%define no_gnome_askpass 1/g" openssh.spec
[root@localhost openssh-9.7p1]# mkdir -p /root/rpmbuild/SPECS
[root@localhost openssh-9.7p1]# mkdir -p /root/rpmbuild/SOURCES
[root@localhost openssh-9.7p1]# rpmbuild -ba openssh.spec
error: Bad source: /root/rpmbuild/SOURCES/x11-ssh-askpass-1.2.4.1.tar.gz: No such file or directory


解决:
%global no_x11_askpass 1


root@localhost openssh-9.7p1]# rpmbuild -ba openssh.spec
error: Bad source: /root/rpmbuild/SOURCES/openssh-9.7p1.tar.gz: No such file or directory
[root@localhost openssh-9.7p1]# cd ../
[root@localhost miao]# ls
Desktop  Documents  Downloads  Music  openssh-9.7p1  openssh-9.7p1.tar.gz  openssl-RPM-Builder  Pictures  Public  Templates  Videos
[root@localhost miao]# cp openssh-9.7p1/openssh.spec  ./
[root@localhost miao]# ls
Desktop  Documents  Downloads  Music  openssh-9.7p1  openssh-9.7p1.tar.gz  openssh.spec  openssl-RPM-Builder  Pictures  Public  Templates  Videos
[root@localhost miao]# rpmbuild -ba openssh.spec
error: Bad source: /root/rpmbuild/SOURCES/openssh-9.7p1.tar.gz: No such file or directory
[root@localhost miao]# cp openssh-9.7p1.tar.gz  /root/rpmbuild/SOURCES/
[root@localhost miao]# cd openssh-9.7p1/


问题3:
[root@localhost openssh-9.7p1]# rpmbuild -ba openssh.spec
error: Failed build dependencies:
    perl is needed by openssh-9.7p1-1.el8.x86_64

解决:
yum install perl

问题4:
checking for openssl... /bin/openssl
checking whether to enable PKCS11... disabled; missing libcrypto
checking whether to enable U2F... yes
checking if /bin/x86_64-redhat-linux-gnu-pkg-config knows about libfido2... no
checking for fido_init in -lfido2... no
checking for fido.h... no
checking for fido/credman.h... no
checking for usable libfido2 installation... missing fido/credman.h from libfido2
checking for arc4random... no
checking for arc4random_buf... no
checking for arc4random_stir... no
checking for arc4random_uniform... no
checking for PRNGD/EGD socket... not found
configure: WARNING: OpenSSH will use /dev/urandom as a source of random numbers. It will fail if this device is not supported or accessible
checking for ia_openinfo in -liaf... no
checking for crypt in -lcrypt... yes
checking for crypt... yes
configure: error: PAM headers not found
error: Bad exit status from /var/tmp/rpm-tmp.cF8TTA (%build)

解决:
yum install pam-devel


报错:
[root@localhost openssh-9.7p1]# rpmbuild -ba openssh.spec
error: Failed build dependencies:
    /usr/include/X11/Xlib.h is needed by openssh-9.7p1-1.el8.x86_64
    gtk2-devel is needed by openssh-9.7p1-1.el8.x86_64
    imake is needed by openssh-9.7p1-1.el8.x86_64
    libXt-devel is needed by openssh-9.7p1-1.el8.x86_64
[root@localhost openssh-9.7p1]# yum install imake

yum install libXt-devel imake gtk2-devel openssl-libs -y

安装imake
wget https://repo.almalinux.org/almalinux/8/PowerTools/x86_64/os/Packages/imake-1.0.7-11.el8.x86_64.rpm
rpm -ivh imake-1*


报错:
Processing files: openssh-debugsource-9.7p1-1.el8.x86_64
error: Could not open %files file /root/rpmbuild/BUILD/openssh-9.7p1/debugsourcefiles.list: No such file or directory


RPM build errors:
    Could not open %files file /root/rpmbuild/BUILD/openssh-9.7p1/debugsourcefiles.list: No such file or directory
解决办法:
在openssh.spec 开头添加文件:%define debug_package %{nil}

卸载:

rpm -e --nodeps openssh-clients-8.0p1-5.el8.x86_64
rpm -e openssh-server-8.0p1-5.el8.x86_64
rpm -e --nodeps openssh-8.0p1-5.el8.x86_64

卸载后安装:
···
rpm -ivh openssh*
···
更改:

[root@localhost x86_64]#  chmod 0600 /etc/ssh/ssh_host_rsa_key
[root@localhost x86_64]#  chmod 0600 /etc/ssh/ssh_host_ecdsa_key
[root@localhost x86_64]# chmod 0600 /etc/ssh/ssh_host_ed25519_key
[root@localhost x86_64]# sshd -t 

后重启项目:

systemctl restart sshd

重启机器后登录不上,查看日志tail -f /var/log/messages

26:48 localhost systemd[1]: Started SYSV: OpenSSH server daemon.
Jun 13 15:26:55 localhost sshd[10655]: error: Could not get shadow information for miao
Jun 13 15:26:55 localhost sshd[10655]: Failed password for miao from 127.0.0.1 port 33740 ssh2
Jun 13 15:26:59 localhost sshd[10655]: Failed password for miao from 127.0.0.1 port 33740 ssh2
Jun 13 15:27:01 localhost sshd[10655]: Failed password for miao from 127.0.0.1 port 33740 ssh2
Jun 13 15:27:01 localhost sshd[10655]: Connection closed by authenticating user miao 127.0.0.1 port 33740 [preauth]
Jun 13 15:28:20 localhost systemd[1]: Starting Check PMIE instances are running...
Jun 13 15:28:20 localhost systemd[1]: pmie_check.service: Succeeded.

还是报错报错:

Jun 13 14:59:26 localhost gdm-launch-environment][3235]: pam_unix(gdm-launch-environment:session): session closed for user gdm
Jun 13 15:04:02 localhost sudo[6284]:    miao : TTY=pts/0 ; PWD=/home/miao ; USER=root ; COMMAND=/bin/bash
Jun 13 15:04:02 localhost sudo[6284]: pam_systemd(sudo:session): Cannot create session: Already running in a session or user slice
Jun 13 15:04:02 localhost sudo[6284]: pam_unix(sudo:session): session opened for user root by (uid=0)
Jun 13 15:20:26 localhost sshd[9214]: PAM unable to dlopen(/usr/lib64/security/pam_stack.so): /usr/lib64/security/pam_stack.so: cannot open shared object file: No such file or directory
Jun 13 15:20:26 localhost sshd[9214]: PAM adding faulty module: /usr/lib64/security/pam_stack.so
Jun 13 15:25:38 localhost sshd[10424]: PAM unable to dlopen(/usr/lib64/security/pam_stack.so): /usr/lib64/security/pam_stack.so: cannot open shared object file: No such file or directory
Jun 13 15:25:38 localhost sshd[10424]: PAM adding faulty module: /usr/lib64/security/pam_stack.so
Jun 13 15:25:40 localhost sshd[10433]: PAM unable to dlopen(/usr/lib64/security/pam_stack.so): /usr/lib64/security/pam_stack.so: cannot open shared object file: No such file or directory
Jun 13 15:25:40 localhost sshd[10433]: PAM adding faulty module: /usr/lib64/security/pam_stack.so
Jun 13 15:30:00 localhost sshd[11376]: PAM unable to dlopen(/usr/lib64/security/pam_stack.so): /usr/lib64/security/pam_stack.so: cannot open shared object file: No such file or directory
Jun 13 15:30:00 localhost sshd[11376]: PAM adding faulty module: /usr/lib64/security/pam_stack.so
Jun 13 15:30:39 localhost sshd[11544]: PAM unable to dlopen(/usr/lib64/security/pam_stack.so): /usr/lib64/security/pam_stack.so: cannot open shared object file: No such file or directory
Jun 13 15:30:39 localhost sshd[11544]: PAM adding faulty module: /usr/lib64/security/pam_stack.so

修改:

selinux配置文件

/etc/selinux/config
修改
SELINUX=enforcing 为 SELINUX=disabled。
重启后可以登录

参考

 链接:https://blog.csdn.net/ycx987/article/details/128421955
https://www.cnblogs.com/the-capricornus/p/17130474.html

相关文章

网友评论

      本文标题:centos8.4下编译openssh9.7

      本文链接:https://www.haomeiwen.com/subject/yrngqjtx.html