Ubuntu 22.04.2安装openssh-server失败求助
Ubuntu 22.04.2安装openssh-server失败求助
问题描述
我在Ubuntu 22.04.2(不是22.04.1)上安装OpenSSH服务器时碰到了麻烦,执行sudo apt install openssh-server后出现了依赖错误,具体报错信息如下:
$ sudo apt install openssh-server Reading package lists... Done Building dependency tree... Done Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: libbsd0:i386 : Depends: libc6:i386 (>= 2.33) but it is not installable libcbor0.8:i386 : Depends: libc6:i386 (>= 2.4) but it is not installable libcom-err2:i386 : Depends: libc6:i386 (>= 2.28) but it is not installable libedit2:i386 : Depends: libc6:i386 (>= 2.33) but it is not installable libfido2-1:i386 : Depends: libc6:i386 (>= 2.33) but it is not installable libgssapi-krb5-2:i386 : Depends: libc6:i386 (>= 2.33) but it is not installable libk5crypto3:i386 : Depends: libc6:i386 (>= 2.33) but it is not installable libkeyutils1:i386 : Depends: libc6:i386 (>= 2.7) but it is not installable libkrb5-3:i386 : Depends: libc6:i386 (>= 2.34) but it is not installable libkrb5support0:i386 : Depends: libc6:i386 (>= 2.34) but it is not installable libmd0:i386 : Depends: libc6:i386 (>= 2.33) but it is not installable libpcre2-8-0:i386 : Depends: libc6:i386 (>= 2.4) but it is not installable libselinux1:i386 : Depends: libc6:i386 (>= 2.34) but it is not installable libssl3:i386 : Depends: libc6:i386 (>= 2.34) but it is not installable libtinfo6:i386 : Depends: libc6:i386 (>= 2.33) but it is not installable libudev1:i386 : Depends: libc6:i386 (>= 2.34) but it is not installable openssh-client:i386 : Depends: libc6:i386 (>= 2.34) but it is not installable zlib1g:i386 : Depends: libc6:i386 (>= 2.4) but it is not installable E: Unable to correct problems, you have held broken packages.
解决方法
看起来核心问题是系统启用了i386架构,但对应的32位libc6包无法安装,同时存在破损锁定的包。试试下面这些步骤:
先检查系统架构配置
打开终端执行这两个命令,看看当前启用的架构:dpkg --print-architecture dpkg --print-foreign-architectures如果输出里有
i386,而你平时不用32位软件的话,直接移除这个架构就行:sudo dpkg --remove-architecture i386 sudo apt update更新完成后再重新运行安装命令:
sudo apt install openssh-server,应该就能正常安装了。如果需要保留i386架构
那得先修复依赖和破损包:- 先尝试自动修复依赖:
sudo apt-get install -f - 清理本地缓存并刷新源,避免缓存损坏导致的问题:
sudo apt clean sudo apt update --fix-missing - 手动安装最核心的依赖包libc6:i386:
sudo apt install libc6:i386
等这个包安装成功后,再重新安装openssh-server。
- 先尝试自动修复依赖:
检查并解除锁定的包
报错里提到了“held broken packages”,可以检查有没有被锁定的包:dpkg --get-selections | grep hold如果有输出的包名,用下面的命令解除锁定(把
<包名>换成实际的包):sudo apt-mark unhold <包名>解除所有锁定后,再执行
sudo apt install -f修复依赖,最后再尝试安装openssh-server。
备注:内容来源于stack exchange,提问作者chess
相关产品推荐
相关产品推荐

