Linux openssh升級8.0

dmcatding發表於2019-05-10

#下載openssh連線


--(1)檢查openssh

# rpm -qa|grep openssh

openssh-clients-6.6.1p1-31.el7.x86_64

openssh-server-6.6.1p1-31.el7.x86_64

openssh-6.6.1p1-31.el7.x86_64


--(2)避免openssh失敗無法登陸安裝telnet

yum install -y telnet-server xinetd --安裝

echo -e 'pts/0\pts/1\npts/2\pts/3'  >>/etc/securetty

systemctl enable xinetd.service

systemctl enable telnet.socket

systemctl start telnet.socket

systemctl start xinetd


--(3)解除安裝舊的openssh

# rpm -e `rpm -qa | grep openssh` --nodeps

如果之前就是原始碼安裝的,找到之前的安裝包,在裡面執行

make uninstall


--(4)安裝必要的軟體:

yum -y install gcc pam pam-devel zlib zlib-devel openssl-devel


--(5)解壓編譯

tar -zxvf openssh-8.0p1.tar.gz

cd openssh-8.0p1

./configure    --prefix=/usr  --sysconfdir=/etc/ssh  --with-md5-passwords --with-zlib --with-ssl-dir=/usr/local/ssl \  

--with-privsep-path=/var/lib/sshd

make

make install


如果遇到如下報錯:chmod 600 /etc/ssh/ssh_host_*

install -v -m755 contrib/ssh-copy-id /usr/bin

install -v -m644 contrib/ssh-copy-id.1 /usr/share/man/man1

install -v -m755 -d /usr/share/doc/openssh-8.0p1

install -v -m644 INSTALL LICENCE OVERVIEW README* /usr/share/doc/openssh-8.0p1



echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config

echo 'UsePAM yes' >> /etc/ssh/sshd_config


cp -p contrib/redhat/sshd.init /etc/init.d/sshd

chmod +x /etc/init.d/sshd

chkconfig --add sshd

chkconfig sshd on

chkconfig --list sshd


--(6)重啟驗證

systemctl restart sshd



--(7)驗證完畢後,關閉telnet服務

vi /etc/securetty

刪除增加的4行:

pts/0

pts/1

pts/2

pts/3


#停止telnet服務

systemctl stop telnet.socket

systemctl disable telnet.socket


systemctl stop xinetd.service

systemctl disable xinetd.service


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30327022/viewspace-2643917/,如需轉載,請註明出處,否則將追究法律責任。

相關文章