我刚刚将我的 Debian 服务器从 Stretch(稳定)升级到 Buster(测试)。
我似乎无法解决的一件奇怪的事情:
$ ssh vlastimil@192.168.0.102 -p [censored] -o ConnectTimeout=5 -i /home/vlastimil/.ssh/id_rsa -vvv
Run Code Online (Sandbox Code Playgroud)
结果是:
OpenSSH_7.6p1 Ubuntu-4, OpenSSL 1.0.2n 7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "192.168.0.102" port [censored]
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 192.168.0.102 [192.168.0.102] port [censored].
debug2: fd 3 setting O_NONBLOCK
debug1: connect to address 192.168.0.102 port [censored]: Connection refused
Run Code Online (Sandbox Code Playgroud)
ssh: connect to host 192.168.0.102 port [censored]: Connection refused
Run Code Online (Sandbox Code Playgroud)
但是,如果我在本地以该用户身份登录(然后我什至可以注销,它只需要一次登录),它确实可以工作。
我能够以 root 身份登录。但是,尽管交换了公钥,但只能来自一台机器。
此外,只需要从那台机器上进行一次 root 登录,然后就可以从另一台机器上以 root 身份登录。
任何人都可以详细说明,我如何调试这个问题?
服务器的配置:
# grep -v '#' /etc/ssh/sshd_config
Port [censored]
Protocol 2
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 120
StrictModes yes
HostbasedAuthentication no
IgnoreRhosts yes
PermitEmptyPasswords no
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
PrintLastLog no
Banner none
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
KeyRegenerationInterval 3600
ServerKeyBits 4096
Ciphers chacha20-poly1305@openssh.com,aes128-gcm@openssh.com
MACs hmac-sha2-512-etm@openssh.com
KexAlgorithms curve25519-sha256@libssh.org
FingerprintHash sha512
Match Address 192.168.0.*
PermitRootLogin yes
Match all
PermitRootLogin no
Run Code Online (Sandbox Code Playgroud)
connection refused表明sshd没有运行。
这可能只是时间问题:当控制台上出现登录提示时,并不能保证所有系统服务都已完成启动。
sshd也可能会卡在等待中/dev/[u]random,尤其是当系统位于网络流量很少的网段时。在这种情况下,系统几乎没有可用的真随机源,并且难以收集足够的真随机位来初始为内核的随机数生成器播种。登录到系统控制台将以键盘中断调用时间的最低位的形式提供一些随机性。如果系统具有某种形式的硬件 RNG,启用它可能会解决此问题。
要诊断,只需在控制台登录提示中输入几行废话,而无需实际登录。 如果sshd之后正常响应,则可能是内核缺乏随机性,无法为内核 RNG 播种,从而导致启动sshd延迟.
或者它可能是某种systemd依赖错误,只允许sshd在与登录相关的进程首先启动时启动。这将是 Debian Buster 仍然是testing发行版的原因之一:如果事实证明这是原因,请发送错误报告。
小智 7
感谢telcoM对硬件 RNG的回答,我做了一个apt search并找到了软件包rng-tools5并安装了它:
sudo apt-get install rng-tools5
Run Code Online (Sandbox Code Playgroud)
这解决了我的英特尔 NUC 上的问题。
编者注:我在带有至强 CPU 的 Dell PowerEdge T20 上的问题也由此解决。
补充说明:
安装包后,请检查是否有随机来源:
rngd -v
Run Code Online (Sandbox Code Playgroud)
就我而言,没有 TPM 设备,但 CPU 具有以下rdrand功能:
Run Code Online (Sandbox Code Playgroud)Unable to open file: /dev/tpm0 Available entropy sources: DRNG
| 归档时间: |
|
| 查看次数: |
8312 次 |
| 最近记录: |