ubuntu2204升级openssh

安装依赖

sh 复制代码
apt update
apt install build-essential zlib1g-dev libssl-dev -y
apt install libpam0g-dev libselinux1-dev libkrb5-dev -y
apt install autoconf -y

mkdir /var/lib/sshd
chmod -R 700 /var/lib/sshd/
chown -R root:sys /var/lib/sshd/

下载最新ssh

sh 复制代码
cd /var/lib/sshd/
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.8p1.tar.gz

编辑安装

sh 复制代码
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/include/openssl --with-ssl-dir=/usr/local/lib --with-zlib --with-md5-passwords --with-pam --with-privsep-path=/var/lib/sshd
sh 复制代码
make && make install

修改配置

如果这里没有允许密码登录,又没有配置免密,那就gg了

根据自己需要调整sshd配置文件,参考如下

sh 复制代码
vim /etc/ssh/sshd_config
sh 复制代码
PermitRootLogin yes                                    #允许root登录,root用户必须添加
AuthorizedKeysFile      .ssh/authorized_keys    #指定公钥文件的保存位置以及名称
PasswordAuthentication yes                             #允许密码验证
UsePAM yes                                                      #PAM模块
UseDNS no                                                        #关闭dns检测

重启ssh

sh 复制代码
systemctl restart ssh

检查版本

sh 复制代码
ssh -V
相关推荐
视觉小萌新14 小时前
A1——基于AMD-48G显卡下载Gemma4模型
linux·ubuntu
MSTcheng.18 小时前
【Linux】Linux学习第三弹——Linux基本指令2
linux·windows·学习·ubuntu·操作系统
苏三福2 天前
ubuntu 在文件管理系统中用sftp打开远程文件空白的问题解决
linux·运维·ubuntu
Anesthesia丶2 天前
llama-server编译部署+opencode验证记录(Ubuntu, GPU)
ubuntu·opencode·llama-server·qwen3.8-9b
Sunqk56652 天前
将开发板串口连接到Ubuntu后未找到对应的设备文件?
linux·运维·ubuntu
YHHLAI2 天前
TypeScript 面试题:type 与 interface 的区别与相同点
java·ubuntu·typescript
玖石书4 天前
Ubuntu 更换 USTC 镜像源完整指南(AMD64 / AARCH64)
linux·运维·ubuntu
牢姐与蒯4 天前
Linux进程(五).之环境变量
linux·运维·服务器·ubuntu
黑臂麒麟4 天前
Harmony鸿蒙实战应用4:随手账本——编辑与删除账单
ubuntu·华为·鸿蒙
玖石书4 天前
WSL2 手动安装 Ubuntu 24.04 到指定磁盘位置
linux·运维·ubuntu·wsl