注意
当只能通过SSH远程链接服务器时,要防止ssh断开,避免安装失误无法控制服务器;
使用putty可以通过设置Seconds between keepaliaves为60防止自动断开;
查看版本
$ openssl version
$ ssh -V
升级openssl
centos7.3——OpenSSL1.0.2升级到OpenSSL 1.1.1.
安装依赖
yum -y install pam-devel
下载解压openssh
$ wget https://mirrors.aliyun.com/openssh/portable/openssh-9.2p1.tar.gz
$ tar zxvf openssh-9.2p1.tar.gz
备份
$ mkdir -p ~/ssh_bak/etc/ssh/ && mkdir -p ~/ssh_bak/usr/bin/ && mv /etc/ssh/ ~/ssh_bak/etc/ssh/ && mv /usr/bin/{ssh*,scp,sftp} ~/ssh_bak/usr/bin/
编译安装
$ cd openssh-9.2p1
$ ./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl --with-pam --with-md5-passwords --with-selinux && make -j 4 && make install
$ echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
$ echo 'UsePAM yes' >> /etc/ssh/sshd_config
查看版本
$ ssh -V
设置开机启动并重启sshd
$ systemctl enable sshd
$ systemctl restart sshd
如启动、登录有问题运行命令查看原因
···bash
$ systemctl status sshd
···