前言:最好先裝Telnet服務防止openssh升級失敗無法遠程服務器
1:查看當前的openssh版本,並備份/etc/ssh/
ssh -V
2:安裝必要的組件
yum install -y gcc openssl-devel pam-devel rpm-build (不同版本的需要安裝的組件可能不同,可根據編譯時的報錯安裝)
3:cd到放安裝包的地方,可隨意,以下soft是隨意寫的,可替換
cd /soft
4: 下載8.0的安裝包以及解壓
wget https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.0p1.tar.gz
tar -zxvf openssh-8.0p1.tar.gz
5:進入openssh-8.0p1目錄
cd openssh-8.0p1/
6:確認電腦上usr和/etc/ssh目錄地址,替換以下的路徑信息信息
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords --with-tcp-wrappers
如果有報錯解決報錯
7:執行
make && make install
8:如果出現如下問題
Permissions 0640 for '/etc/ssh/ssh_host_ecdsa_key' are too open
解決:
修改相關提示文件的權限為600,如有其他文件也報上面的錯也同樣操作
例如:chmod 600 /etc/ssh/ssh_host_ecdsa_key
9:查看現在的版本,應該是8.0了
ssh -V
10.修改配置文件
編輯ssh配置文件:
vim /etc/ssh/sshd_config 配置:
PasswordAuthentication yes
如果要允許root用戶ssh登錄需要配置:PermitRootLogin yes
11.設置開機啟動
cd openssh-8.0p1/
cp -a contrib/redhat/sshd.init /etc/init.d/sshd
cp -a contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
chmod +x /etc/init.d/sshd
chkconfig --add sshd
systemctl enable sshd
mv /usr/lib/systemd/system/sshd.service /tmp
chkconfig sshd on
11.重啟服務
服務重啟 service sshd restart
查看服務狀態(systemctl status sshd.service)
查看當前ssh版本: ssh -V
12.測試是否成功
1.測試與其他服務器能否互聯
如有報錯,有可能是不同版本之間的加密方式不同,導致不可用
解決方法:
將 /root/.ssh/authorized_keys里面的對應ip的加密串刪除,省事就全部刪了吧,哈哈哈
2. 在升級后的機器ssh其他服務器出現如下報錯:
/etc/ssh/ssh_config line 59: Unsupported option "gssapiauthentication"
解決方法:
注釋掉客戶端配置文件 /etc/ssh/ssh_config : GSSAPIAuthentication yes 這一行
其他:我覺得寫得很好的博客,使用構建rpm包的方式升級openssh
https://www.cnblogs.com/liao-lin/p/10286722.html#commentform