準(zhǔn)備工作
下載源碼包乳蓄、創(chuàng)建rpm包制作所需相關(guān)的目錄
開始rpm制作
1眶诈、檢查本機(jī)openssh版本,查看yum源中最新的版本
ssh -V
yum info openssh
2友题、建立目錄下載源碼包
cd /opt
mkdir -pv openssh/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
wget https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-7.5p1.tar.gz -O openssh/SOURCES/openssh-7.5p1.tar.gz
#下載x11支持包
wget http://pkgs.fedoraproject.org/repo/pkgs/openssh/x11-ssh-askpass-1.2.4.1.tar.gz/8f2e41f3f7eaa8543a2440454637f3c3/x11-ssh-askpass-1.2.4.1.tar.gz -O openssh/SOURCES/x11-ssh-askpass-1.2.4.1.tar.gz
3、開始制作
cd openssh/SOURCES
tar xf openssh-7.5p1.tar.gz
cp openssh-7.5p1/contrib/redhat/openssh.spec ../SPECS
修改編譯配置文件
#進(jìn)入文件夾
cd ../SPECS/
#按需修改以下內(nèi)容:
# Do we want to disable building of x11-askpass? (1=yes 0=no)
%define no_x11_askpass 1
# Do we want to disable building of gnome-askpass? (1=yes 0=no)
%define no_gnome_askpass 1
使用rpmbuild制作rpm包戴质,完成后在RPMS下生成rpm安裝包
rpmbuild -bb openssh.spec
4度宦、上傳rpm包到服務(wù)器進(jìn)行安裝 ,安裝前備份配置文件告匠,以免被覆蓋
yum -y install ./openssh*.rpm
# 或者使用
rpm -ivh *.rpm
以下是使用腳本進(jìn)行安裝升級的操作
mkdir /opt/backup
mv /etc/ssh /opt/backup
cp /etc/pam.d/sshd /opt/backup/sshd.pam
yum -y install ./openssh*.rpm
mv /etc/ssh/sshd_config{,.old_$(date '+%s')}
cat > /etc/ssh/sshd_config << SSHDEOF
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
PermitRootLogin yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication yes
ChallengeResponseAuthentication no
UsePAM yes
Subsystem sftp /usr/libexec/openssh/sftp-server
SSHDEOF
mv /etc/pam.d/sshd{,.old_$(date '+%s')}
cp /opt/backup/sshd.pam /etc/pam.d/sshd
service sshd restart