下载openssh-9.6p1
https://www.openssh.com/ftp.html
tar xvf openssh-9.6p1.tar.gz
安装编译器和依赖库
apt-get install gcc
apt-get install zlib1g-dev
apt-get install libssl-dev
apt-get install make
编译
./configure
make
安装
make install
为了使现在版本生效卸载掉以前版本
apt-get remove openssh-client
在更新openssh后修改/etc/systemd/system/multi-user.target.wants/ssh.service服务文件切记在服务修改之前不要重启机器
[Unit]
Description=OpenBSD Secure Shell server
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
[Service]
EnvironmentFile=-/etc/default/ssh
ExecStartPre=/usr/local/sbin/sshd -t
ExecStart=/usr/local/sbin/sshd -D $SSHD_OPTS
ExecReload=/usr/local/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify
RuntimeDirectory=sshd
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target
Alias=sshd.service