CentOS openssh 升级教程

安装关联软件包和编译工具包

yum update openssl openssh -y
yum install vim gcc gcc-c++ glibc make autoconf openssl-devel pcre-devel pam-devel zlib-devel rsync -y
yum install pam* zlib* -y

下载源码安装包

mkdir -p /opt/openssh || cd /opt/openssh
wget https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-8.7p1.tar.gz

源码编译

cd /opt/openssh && tar -zxvf openssh-8.7p1.tar.gz && cd /opt/openssh/openssh-8.7p1
mv /etc/ssh /etc/ssh_bak
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-md5-passwords --with-zlib --with-pam
make
# 先卸载openssh再执行 make install
rpm -e --nodeps `rpm -qa | grep openssh`
make install

修改配置文件

echo "
Protocol 2
SyslogFacility AUTHPRIV
PermitRootLogin yes
PasswordAuthentication yes
ChallengeResponseAuthentication no
# UseLogin no
X11Forwarding yes
# 开启公钥验证
PubkeyAuthentication yes
" >> /etc/ssh/sshd_config

修改启动脚本和开机启动

# 拷贝启动脚本
rsync -avb ./contrib/redhat/sshd.init /etc/init.d/sshd
rsync -avb ./contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
chmod +x /etc/init.d/sshd

## 添加开机启动
chkconfig sshd on

复制可执行文件并重新启动服务

rsync -avb /usr/local/openssh/bin/* /usr/bin/
rsync -avb /usr/local/openssh/sbin/* /usr/sbin/

/etc/init.d/sshd restart
上一篇:linux 创建 service


下一篇:【macOS】IDEA 里面的git fetch 拉不到远程分支