debian系統升級openssh
最近護網行動開始了,公司的老的服務器開始修補漏洞,今天我修補的漏洞是openssh,
OpenSSH 是 SSH (Secure SHell) 協議的免費開源實作,SSH協議族可以用來進行遠程控制, 或在計算機之間傳送檔案,而實作此功能的傳統方式,如telnet(終端仿真協議)、 rcp ftp、 rlogin、rsh都是極為不安全的,并且會使用明文傳送密碼,OpenSSH提供了服務端后臺程式和客戶端工具,用來加密遠程控制和檔案傳輸程序中的資料,并由此來代替原來的類似服務,
#首先我們看下自己服務器的ssh版本,現在最新版本是8.5
root@hecs-x-medium-2-linux-20210317100343:/opt# ssh -V
OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019
root@hecs-x-medium-2-linux-20210317100343:/opt# vim updatessh.sh
#將下面內容依次執行也可以,或者復制在腳本中執行,切記腳本執行報錯就不要執行第二次,腳本報錯就開始排查腳本執行到哪步報錯,然后解決報錯的問題依次執行腳本下面內容即可
##### openssh升級到8.5命令
# 安裝依賴
apt-get install -y aptitude
aptitude install -y libpam0g-dev libselinux1-dev
apt-get install -y libssl-dev zlib1g-dev
# 備份ssh配置
cp -rf /etc/ssh /etc/ssh.bak
# 設定檔案權限
chmod 600 /etc/ssh/ssh_host_rsa_key
chmod 600 /etc/ssh/ssh_host_ecdsa_key
chmod 600 /etc/ssh/ssh_host_ed25519_key
# 配置sshd配置
sed -i 's/^#PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config
sed -i 's/^GSSAPIAuthentication/#&/' /etc/ssh/sshd_config
sed -i 's/^GSSAPICleanupCredentials/#&/' /etc/ssh/sshd_config
sed -i 's/^UsePAM/#&/' /etc/ssh/sshd_config
# 配置service, 取消notify
sed -i 's/^Type/#&/' /lib/systemd/system/ssh.service
# 下載包
wget https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.5p1.tar.gz
tar zxf openssh-8.5p1.tar.gz
# 編譯安裝
cd openssh-8.5p1
./configure --prefix=/usr --with-privsep-path=/var/empty/sshd/ \
--sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl/ \
--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-pam --with-selinux --disable-strip --with-md5-passwords
make
make install
# 重啟服務
systemctl daemon-reload
systemctl restart sshd
# 現在版本
ssh -V
root@hecs-x-medium-2-linux-20210317100343:/opt# bash updatessh.sh
#執行腳本最后成功的標志是ssh變成8.5,因為腳本最后的ssh -V就是回傳當前ssh的版本號,我記得我上次離職的時候公司正在升級8.5的版本,我今天升級的8.1,明天過去給升級成8.5,今天在我的服務器已經測驗了,
root@hecs-x-medium-2-linux-20210317100343:/opt# ssh -V
OpenSSH_8.5p1, OpenSSL 1.1.1d 10 Sep 2019
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/276716.html
標籤:其他
上一篇:cube可信框架之檔案加解密傳輸
下一篇:攻防世界-新手練習crypto2
