我正在尝试用这个启动虚拟机盒子“debian/bookworm64”,但它在 ssh 身份验证期间超时。我使用相同的 Vagrantfile,ubuntu/focal64
它在那里工作正常。使用 ubuntu:20.04 框时,我没有遇到 ssh 身份验证问题,为什么使用 debian:12?但我可以在超时vagrant ssh
后进入虚拟机vagrant up
。但 Vagrantfile 的配置步骤不会启动,这是我需要的。我偶然发现了这个答案Debian 线程:
Ubuntu 20.04 “jammy” 有 ruby-net-ssh 6.1.0。该版本无法连接到最新的 OpenSSH,如 Debian bookworm 中所述。在 Debian bullseye 中,ruby-net-ssh 已更新至版本 1:6.1.0-2+deb11u1 以解决此问题。Ubuntu 中可能需要相同的更新。
这是 Ubuntu 中发布的最新版本:20.04:。
ruby-net-ssh is already the newest version (1:5.2.0-1)
这可能是问题所在吗?其他人是否在 debian/bookworm64 或其他机器上遇到过类似的问题?
我已经尝试了几种方法,例如检查 .ssh/authorized_keys 是否chmod 0600
在虚拟机上,是否.vagrant.d/insecure_private_key
在主机的主路径中。我的意思是vagrant ssh
有效,为什么当 vagrant 尝试配置新虚拟机时 ssh 身份验证不起作用?
Vagrant文件:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# config.vm.box = "ubuntu/focal64"
config.vm.box = "debian/bookworm64"
config.vm.hostname = "test02"
config.vm.provider "virtualbox" do |v|
v.name = "debian12"
v.memory = 4096
v.cpus = 2
end
end
错误日志:
D, [2023-11-07T18:03:35.124736 #896133] DEBUG -- net.ssh.authentication.session[3a9a8]: allowed methods: publickey
E, [2023-11-07T18:03:35.124763 #896133] ERROR -- net.ssh.authentication.session[3a9a8]: all authorization methods failed (tried none, publickey)
DEBUG ssh: == Net-SSH connection debug-level log END ==
INFO ssh: SSH not ready: #<Vagrant::Errors::SSHAuthenticationFailed: SSH authentication failed! This is typically caused by the public/private
keypair for the SSH user not being properly set on the guest VM. Please
verify that the guest VM is setup with the proper public key, and that
the private key path for Vagrant is setup properly as well.>
进一步查看日志:
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
答案1
好吧,我终于解决了!我认为原因是ruby-net-ssh
我们将服务器从 Ubuntu 20.04 升级到 22.04,并vagrant up
最终通过 ssh 身份验证步骤来配置虚拟机