#下载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