安裝gcc
yum install gcc -y
安裝perl-devel
yum install perl-devel
安裝openssl-devel
yum install -y openssl-devel
編譯
tar -zxvf openssh-8.3p1.tar.gz
cd openssh-8.3p1
./configure --prefix=/usr/local/openssh --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl --with-zlib=/usr/local/zlib --with-md5-passwords && make && make install
注:此處若是重新安裝了最新的openssl,則填寫安裝地址,如下圖
備份啓動腳本/etc/init.d
cp -p /etc/init.d/sshd /etc/init.d/sshd.lod_$(date +%Y-%m-%d_%H-%M)
刪除舊的並複製新的
rm /etc/init.d/sshd
cp -p contrib/redhat/sshd.init /etc/init.d/sshd
賦予執行權限
chmod u+x /etc/init.d/sshd
加入開機啓動
chkconfig --add sshd
chkconfig sshd on
修改或查看配置
vi /etc/ssh/sshd_config
PermitRootLogin yes
X11Forwarding yes
PubkeyAuthentication yes
授權並重啓:
chmod 600 /etc/ssh/ssh_host_rsa_key
chmod 600 /etc/ssh/ssh_host_ecdsa_key
/etc/init.d/sshd restart / service sshd restart
檢查版本:
ssh -V
問題
- 提示下面關於openssl的錯(若是ssh版本與ssl不匹配,則先升級openssl版本)
configure: error: *** OpenSSL headers missing - please install first or check config.log ***
解決辦法:查看此處路徑是否爲自己安裝openssl的路徑