2022年3月6日 星期日

CentOS 7 更新 sshd 版本

Reference:
 
安裝需要的工具
yum -y install wget tar gcc make perl
 
download zlib last version
到 https://zlib.net/ 確認最新版本
wget https://zlib.net/zlib-1.2.11.tar.gz

download openssl last version
到 https://www.openssl.org/source/ 確認最新版本
wget https://www.openssl.org/source/openssl-1.1.1m.tar.gz

download openssh last version
到 https://www.openssh.com/ 確認最新版本
https://www.openssh.com/portable.html
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.9p1.tar.gz
 

解壓縮
tar --no-same-owner -zxvf zlib-1.2.11.tar.gz
tar --no-same-owner -zxvf openssl-1.1.1m.tar.gz
tar --no-same-owner -zxvf openssh-8.9p1.tar.gz

install zlib
cd ~/zlib-1.2.11
./configure --prefix=/usr/local/zlib
make && make install

install openssl
cd ~/openssl-1.1.1m
./config --prefix=/usr/local/ssl -d shared
echo '/usr/local/ssl/lib' >> /etc/ld.so.conf
ldconfig -v

install openssh
cd ~/openssh-8.9p1
./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/ssl
make && make install

解除由yum安裝的openssh
yum remove openssh

vi /usr/local/openssh/etc/sshd_config
PermitRootLogin yes
PubkeyAuthentication yes
PasswordAuthentication yes

cp ~/openssh-8.9p1/contrib/redhat/sshd.init /etc/init.d/sshd
chkconfig --add sshd
cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config
cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
cp /usr/local/openssh/bin/ssh /usr/bin/ssh
cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
cp /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub

service sshd restart

沒有留言:

張貼留言