Ssh

無法在 debian 10.4 上安裝 sshd (openssh-server)

  • May 25, 2020

這是 Debian-10.4 的全新安裝。sources.list 文件如下:

deb cdrom:[Debian GNU/Linux 10.4.0 Buster - Official amd64 DVD Binary-1 20200 0509-10:26]/ buster contrib main

deb http://security.debian.org/debian-security buster/updates main contrib
deb-src http://security.debian.org/debian-security buster/updates main contrib

# buster-updates, previously known as 'volatile'
# A network mirror was not selected during install.  The following entries
# are provided as examples, but you should amend them as appropriate
# for your mirror of choice.
#
deb http://deb.debian.org/debian/ buster-updates main contrib
deb-src http://deb.debian.org/debian/ buster-updates main contrib

當我嘗試安裝 sshd (openssh-serverr) 我得到這個:

[root@smb4-a ~]# apt install -f openssh-server
Reading package lists... Done
Building dependency tree       
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:
openssh-server : Depends: openssh-client (= 1:7.9p1-10+deb10u1) but 1:7.9p1-10+deb10u2 is to be installed
                 Depends: openssh-sftp-server but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

我什至不會去想像什麼樣的發行版不提供作為基本安裝的一部分的安全遠端訪問。無論 Debian 的原因是什麼,我都需要這樣。問題似乎是這樣的:

openssh-server : Depends: openssh-client (= 1:7.9p1-10+deb10u1) but 1:7.9p1-10+deb10u2 is to be installed

如何強制安裝損壞的依賴項?

更多資訊:

[root@smb4-a ~]# apt-get update
Get:1 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]
Hit:2 http://security.debian.org/debian-security buster/updates InRelease
Get:3 http://deb.debian.org/debian buster-updates/main Sources [3,088 B]
Get:4 http://deb.debian.org/debian buster-updates/main amd64 Packages [7,380 B]
Get:5 http://deb.debian.org/debian buster-updates/main Translation-en [5,166 B]
Fetched 64.9 kB in 0s (358 kB/s)           
Reading package lists... Done
[root@smb4-a ~]# apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

更多的資訊:

# apt policy openssh-*
openssh-sftp-server:
 Installed: (none)
 Candidate: 1:7.9p1-10+deb10u1
 Version table:
    1:7.9p1-10+deb10u1 500
       500 http://security.debian.org/debian-security buster/updates/main amd64 Packages
openssh-tests:
 Installed: (none)
 Candidate: 1:7.9p1-10+deb10u1
 Version table:
    1:7.9p1-10+deb10u1 500
       500 http://security.debian.org/debian-security buster/updates/main amd64 Packages
openssh-server:
 Installed: (none)
 Candidate: 1:7.9p1-10+deb10u1
 Version table:
    1:7.9p1-10+deb10u1 500
       500 http://security.debian.org/debian-security buster/updates/main amd64 Packages
openssh-client:
 Installed: 1:7.9p1-10+deb10u2
 Candidate: 1:7.9p1-10+deb10u2
 Version table:
*** 1:7.9p1-10+deb10u2 100
       100 /var/lib/dpkg/status
    1:7.9p1-10+deb10u1 500
       500 http://security.debian.org/debian-security buster/updates/main amd64 Packages

似乎在安裝過程中,您對“使用網路鏡像?”的問題回答了“否”,因此您的系統配置為沒有鏡像(或者您在安裝過程中可能沒有網路連接)。順便說一句,這由您的 sources.list 指示:

# A network mirror was not selected during install.  The following entries
# are provided as examples, but you should amend them as appropriate
# for your mirror of choice.

所以現在你有一個不完整的sources.list,其中包含更新和安全修復,但不包含基本系統。我不知道 DVD 行是如何從您的 中註釋掉的sources.list,因為如果沒有網路鏡像,安裝程序不會將其刪除。

您必須配置鏡像才能正確安裝軟體包。將此行添加到您的sources.list

deb http://ftp.us.debian.org/debian/ buster main contrib non-free

並執行apt update。之後,您可以安裝openssh-server.

您可能希望將鏡像切換到離您更近的位置,這可以通過更改usURL 的一部分以對應於您的國家或提供不同的鏡像來完成。鏡像站點列表可在此處獲得。

或者,您可以安裝該netselect-apt軟體包,它將搜尋您附近最快的鏡像。

附帶說明:Debian 確實提供了一個安全的遠端 shell,您所要做的就是在安裝過程中在“軟體選擇”頁面上勾選“SSH 伺服器”(為什麼預設情況下不選擇它,我無法理解,但仍然如此)。

引用自:https://serverfault.com/questions/1018278