linux ssh.rpm包下载,openssh RPM包制作

openssh经常出现漏洞要补丁,然而一台的编译安装又太麻烦,如果能有rpm包进行升级安装就很轻松了。下面是参加一些前辈的经验制作rpm包的过程,请大家指正!

1.#依赖安装

yum install rpm-build gcc make wget openssl-devel krb5-devel pam-devel libX11-devel xmkmf libXt-devel initscripts

4.#解压编译文件,或者直接自己写

cd /usr/src/redhat/SOURCES/

# 也可以解压出整包 从里面提取出 openssh-7.5p1/contrib/redhat/openssh.spec 该文件

tar xf openssh-7.9p1.tar.gz openssh-7.9p1/contrib/redhat/openssh.spec

mv openssh-7.9p1/contrib/redhat/openssh.spec ../SPECS/

chown sshd:sshd /usr/src/redhat/SPECS/openssh.spec

cp /usr/src/redhat/SPECS/openssh.spec /usr/src/redhat/SPECS/openssh.spec_def

修改几个配置选项 可选项

#关掉no_gnome_askpass no_x11_askpass这两个参数

sed -i -e "s/%define no_gnome_askpass 0/%define no_gnome_askpass 1/g" /usr/src/redhat/SPECS/openssh.spec

sed -i -e "s/%define no_x11_askpass 0/%define no_x11_askpass 1/g" /usr/src/redhat/SPECS/openssh.spec

#实际编译参数:(spec文件里有注明)

./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --target=x86_64-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/etc/ssh --libexecdir=/usr/libexec/openssh --datadir=/usr/share/openssh --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-privsep-path=/var/empty/sshd --with-md5-passwords --with-tcp-wrappers --with-pam --with-kerberos5=/usr

configure: WARNING: unrecognized options: --with-tcp-wrappers

#可以用这个命令查看编译文件里面的参数值 /usr/src/redhat/SPECS/openssh.spec

#rpm --eval "%{?dist}"

#rpm --eval "%{?ver}"

#很多是在文件里设置的初值,部分是在系统文件里定义的,系统默认的变量定义在这个文件 #vim /usr/lib/rpm/macros

#我只修改了这2行

vim openssh.spec

%define no_x11_askpass 0

%define no_gnome_askpass 0

拷贝安装软件到预编译目录

mkdir -p ~/rpmbuild/SOURCES/

cp /usr/src/redhat/SOURCES/openssh-7.9p1.tar.gz ~/rpmbuild/SOURCES/

cp /usr/src/redhate/SOURCES/x11-ssh-askpass-1.2.4.1.tar.gz ~/rpmbuild/SOURCES/

#执行编译操作

cd /usr/src/redhat/SPECS/

rpmbuild -ba openssh.spec

##############################################################

#安装包的目录如下

ll /root/rpmbuild/RPMS/x86_64/openssh-*

-rw-r--r-- 1 root root 484024 12月 21 10:41 openssh-7.9p1-1.el6.x86_64.rpm

-rw-r--r-- 1 root root 625176 12月 21 10:41 openssh-clients-7.9p1-1.el6.x86_64.rpm

-rw-r--r-- 1 root root 3006728 12月 21 10:41 openssh-debuginfo-7.9p1-1.el6.x86_64.rpm

-rw-r--r-- 1 root root 393156 12月 21 10:41 openssh-server-7.9p1-1.el6.x86_64.rpm

##############################################################

#备份原有的openssh服务

mkdir -p /backup/openssh_def

cd /backup/openssh_def

tar cvzf etc_ssh.tar.gz /etc/ssh

cp /etc/pam.d/sshd /etc/pam.d/system-auth .

cp -p /etc/pam.d/sshd /etc/pam.d/sshddate +%Y%m%d

cp -p /etc/pam.d/system-auth /etc/pam.d/system-authdate +%Y%m%d

cp -p /etc/ssh/sshdconfig .

cp -p /etc/ssh/sshconfig .

#执行升级操作

rpm -Uvh /root/rpmbuild/RPMS/x86_64/*.rpm

把新的 /etc/pam.d/sshd文件备份,并恢复原来版本的 /etc/pam.d/sshd

cp -p /etc/pam.d/sshd /root/sshd.afterupgrade

cp /root/sshd.orig /etc/pam.d/sshd

开启PAM

vi /etc/ssh/sshd_config

UsePAM yes

重启sshd服务

#CentOS 6

service sshd restart

#CentOS 7

#systemctl restart sshd

##########################################################################

升级后出现的错误及解决方案:

重启报错或者ssh无法登录"no hostkey alg"

rm -r /etc/ssh/ssh*key

systemctl restart sshd

#或者重新生成ssh主机密钥

ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key

ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key

ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key

ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key

启动sshd正常,但登录时出现密码验证错误,但密码实际是正确的

这种情况一般是 /etc/pam.d/sshd文件问题,恢复之前备份即可

用xshell之类的工具ssh登录,报错:

linux ssh.rpm包下载,openssh RPM包制作_第1张图片

这种报错生成ssh主机密钥解决(参考1 重启报错或者ssh无法登录"no hostkey alg")

你可能感兴趣的:(linux,ssh.rpm包下载)