即使在创建时,vagrant 也永远无法通过 ssh 连接到我的 ubuntu 框。

vagrant will never be able to ssh to my ubuntu box even while creating.

我对 Vagrant box bento/ubuntu-16.04 有疑问,只有这个 box vagrant 即使在创建时也永远无法通过 ssh 连接到构建的 VM

我尝试使用密钥配置 ssh 一次,通过用户名和密码配置一次,但仍然出现相同的错误,尝试删除框并再次添加,同样的问题

使用:- ubuntu 16.04 作为主要 OS 流浪者 1.9.4 虚拟机:5.0.40 流浪盒:bento/ubuntu-16.04 流浪文件 "ssh using password"

Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-16.04"
  config.vm.hostname = "myubuntu"
  config.ssh.username = "soso"
  config.ssh.password = "soso"

end

这是当我 运行 vagrant 使用上述 vagrant 文件时发生的情况。

$vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/ubuntu-16.04'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/ubuntu-16.04' is up to date...
==> default: Setting the name of the VM: issue_default_1497215548452_86309
==> default: Fixed port collision for 22 => 2222. Now on port 2202.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2202 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2202
    default: SSH username: soso
    default: SSH auth method: password
soso@127.0.0.1's password:
soso@127.0.0.1's password:
    default: Warning: Authentication failure. Retrying...
soso@127.0.0.1's password:
soso@127.0.0.1's password:
soso@127.0.0.1's password:
soso@127.0.0.1's password:
    default: Warning: Authentication failure. Retrying...
soso@127.0.0.1's password:

这里是“--debug”日志的一部分,当它开始要求我输入密码时。这保持循环并每秒炫耀。不知道有没有关系

 INFO subprocess: Starting process: ["/usr/bin/VBoxManage", "showvminfo", "11fd95c4-1632-4fe9-93d8-4e3641e76b72", "--machinereadable"]
 INFO subprocess: Command not in installer, restoring original environment...
DEBUG subprocess: Selecting on IO
DEBUG subprocess: stdout: name="issue_default_1497215719513_409"
groups="/"
ostype="Ubuntu (64-bit)"
UUID="11fd95c4-1632-4fe9-93d8-4e3641e76b72"
CfgFile="/home/abbas/VirtualBox VMs/issue_default_1497215719513_409/issue_default_1497215719513_409.vbox"
SnapFldr="/home/abbas/VirtualBox VMs/issue_default_1497215719513_409/Snapshots"
LogFldr="/home/abbas/VirtualBox VMs/issue_default_1497215719513_409/Logs"
hardwareuuid="11fd95c4-1632-4fe9-93d8-4e3641e76b72"
memory=1024
pagefusion="off"
vram=8
cpuexecutioncap=100
hpet="off"
chipset="piix3"
firmware="BIOS"
cpus=1
pae="on"
longmode="on"
cpuid-portability-level=0
bootmenu="messageandmenu"
boot1="disk"
boot2="dvd"
boot3="none"
boot4="none"
acpi="on"
ioapic="on"
biossystemtimeoffset=0
rtcuseutc="on"
hwvirtex="on"
nestedpaging="on"
largepages="on"
vtxvpid="on"
vtxux="on"
paravirtprovider="default"
VMState="running"
VMStateChangeTime="2017-06-11T21:15:21.448000000"
monitorcount=1
accelerate3d="off"
accelerate2dvideo="off"
teleporterenabled="off"
teleporterport=0
teleporteraddress=""
teleporterpassword=""
tracing-enabled="off"
tracing-allow-vm-access="off"
tracing-config=""
autostart-enabled="off"
autostart-delay=0
defaultfrontend=""
storagecontrollername0="IDE Controller"
storagecontrollertype0="PIIX4"
storagecontrollerinstance0="0"
storagecontrollermaxportcount0="2"
storagecontrollerportcount0="2"
storagecontrollerbootable0="on"
storagecontrollername1="SATA Controller"
storagecontrollertype1="IntelAhci"
storagecontrollerinstance1="0"
storagecontrollermaxportcount1="30"
storagecontrollerportcount1="1"
storagecontrollerbootable1="on"
"IDE Controller-0-0"="none"
"IDE Controller-0-1"="none"
"IDE Controller-1-0"="none"
"IDE Controller-1-1"="none"
"SATA Controller-0-0"="/home/abbas/VirtualBox VMs/issue_default_1497215719513_409/ubuntu-16.04-amd64-disk001.vmdk"
"SATA Controller-ImageUUID-0-0"="ada6bc87-b77f-4697-852d-313419f46319"
natnet1="nat"
macaddress1="080027E889C6"
cableconnected1="on"
nic1="nat"
nictype1="82540EM"
nicspeed1="0"
mtu="0"
sockSnd="64"
sockRcv="64"
tcpWndSnd="64"
tcpWndRcv="64"
Forwarding(0)="ssh,tcp,127.0.0.1,2202,,22"
nic2="none"
nic3="none"
nic4="none"
nic5="none"
nic6="none"
nic7="none"
nic8="none"
hidpointing="ps2mouse"
hidkeyboard="ps2kbd"
uart1="off"
uart2="off"
uart3="off"
uart4="off"
lpt1="off"
lpt2="off"
audio="pulse"
clipboard="disabled"
draganddrop="disabled"
SessionName="headless"
VideoMode="800,600,32"@0,0 1
vrde="on"
vrdeport=5925
vrdeports="5925"
vrdeaddress="127.0.0.1"
vrdeauthtype="null"
vrdemulticon="off"
vrdereusecon="off"
vrdevideochannel="off"
vrdeproperty[TCP/Ports]="5925"
vrdeproperty[TCP/Address]="127.0.0.1"
usb="off"
ehci="off"
xhci="off"
SharedFolderNameMachineMapping1="vagrant"
SharedFolderPathMachineMapping1="/home/abbas/issue"
VRDEActiveConnection="off"
VRDEClients=0
vcpenabled="off"
vcpscreens=0
vcpfile="/home/abbas/VirtualBox VMs/issue_default_1497215719513_409/issue_default_1497215719513_409.webm"
vcpwidth=1024
vcpheight=768
vcprate=512
vcpfps=25
GuestMemoryBalloon=0
GuestOSType="Linux26_64"
GuestAdditionsRunLevel=2
GuestAdditionsVersion="5.1.21 r115005"
GuestAdditionsFacility_VirtualBox Base Driver=50,1497215732634
GuestAdditionsFacility_VirtualBox System Service=50,1497215735252
GuestAdditionsFacility_Seamless Mode=0,1497215732634
GuestAdditionsFacility_Graphics Mode=0,1497215732634
DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000
DEBUG subprocess: Exit status: 0

Vagrant 文件“使用 vagrant isecure 密钥”

Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-16.04"
  config.vm.hostname = "myubuntu"
  config.ssh.username = "soso"
  config.ssh.insert_key = false
  ## making sure it is using the right key
  config.ssh.private_key_path = '/home/abbas/.vagrant.d/insecure_private_key'
end

这是当我 运行 vagrant 使用上述 vagrant 文件时发生的情况。

$vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/ubuntu-16.04'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/ubuntu-16.04' is up to date...
==> default: Setting the name of the VM: issue_default_1497216190372_85398
==> default: Fixed port collision for 22 => 2222. Now on port 2202.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2202 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2202
    default: SSH username: soso
    default: SSH auth method: private key
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...

您不能使用自己的 username 登录,除非您已经创建了自己的帐户。 public box 的默认约定是创建一个 vagrant 用户,因此除非明确指定或者您已经为特定用户创建了自己的 box(例如通过 packer),否则您需要使用 vagrant 用户登录。

删除您的 config.ssh.usernameconfig.ssh.password 或替换为 vagrant 用户,这样您就可以登录