Linux 部署或升級openssh7.5p1


      運維Linux系統,部署或升級openssh是經常面臨的事,以下已redhat6和redhat7為例。

      在redhat6中部署openssh會有什么坑,在編輯openssh源碼包時會報一些類似的錯誤,如下:

     checking OpenSSL header version... 10000003 (OpenSSL 1.0.0 29 Mar 2010)
     checking OpenSSL library version... configure: error: OpenSSL >= 1.0.1 required (have "10000003 (OpenSSL 1.0.0-fips 29 Mar 2010)")

  checking OpenSSL header version... not found
     configure: error: OpenSSL version header not found.

     這是原因openssh在編輯時加上--without-hardening. 下面是寫的一個shell安裝openssh的過程. 在redhat7中沒有這個問題.

openssh安裝腳本

#!/bin/bash
# soft openssh install

ftp -n <<EOF
open 10.204.202.67
user itom 1qaz)P(O
binary
cd soft
lcd /tmp
prompt
get openssh-7.5p1.zip
close
bye
EOF


# rpm -e ssh
ps -ef |grep sshd | grep -v grep
if [ $? -eq 0 ];then
service sshd stop
fi

LIST=`rpm -qa |grep openssh`
for i in $LIST
do
rpm -e $i --nodeps
if [ $? -eq 0 ];then
echo "$i rpm delete ok"
else
echo "$i rpm delete warn"
fi
done
if [ -d /etc/ssh ];then
mv /etc/ssh /etc/ssh.bak
fi

DIRSOFT='/tmp'
if [ -f $DIRSOFT/openssh-7.5p1.zip ];then
unzip openssh-7.5p1.zip
fi

# install zlib
sleep 3
cd zlib-1.2.11
./configure --prefix=/usr/local/zlib && make && make install
if [ $? -eq 0 ];then
echo "soft zlib install ok!"
fi
sleep 1

# install openssl
cd $DIRSOFT
tar -xzvf openssl-1.0.2l.tar.gz > /dev/null
sleep 3
cd openssl-1.0.2l
./config --prefix=/usr/local/openssl && make && make install
if [ $? -eq 0 ];then
echo "soft openssl install ok!"
fi
sleep 1
echo "/usr/local/openssl/lib/" >> /etc/ld.so.conf
ldconfig

# install openssh
cd $DIRSOFT
tar -xzvf openssh-7.5p1.tar.gz > /dev/null
sleep 3
cd openssh-7.5p1
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl
--with-zlib=/usr/local/zlib --with-md5-passwords --without-hardening && make && make install
if [ $? -eq 0 ];then
echo "soft openssh install ok!"
fi
sleep 1

cp contrib/redhat/sshd.init /etc/init.d/sshd
sed -i 's/SSHD=\/usr\/sbin\/sshd/SSHD=\/usr\/local\/openssh\/sbin\/sshd/g' /etc/init.d/sshd
sed -i 's/\/usr\/bin\/ssh-keygen -A/\/usr\/local\/openssh\/bin\/ssh-keygen -A/g' /etc/init.d/sshd

chkconfig --add sshd
service sshd start
echo "export PATH=/usr/local/openssh/bin:$PATH" >> /etc/profile

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM