centos8.4下编译openssh9.7

一 准备

在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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,185评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,445评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,684评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,564评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,681评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,874评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,025评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,761评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,217评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,545评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,694评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,351评论 4 332
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,988评论 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,778评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,007评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,427评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,580评论 2 349

推荐阅读更多精彩内容