linux - 即使在创建时,vagrant 也永远无法 ssh 到我的 ubuntu 盒子。

标签 linux ubuntu ssh vagrant virtualbox

我有 Vagrant box Bento/ubuntu-16.04 的问题,只有这个 box vagrant 即使在创建时也永远无法 ssh 到构建的虚拟机

我尝试使用 key 配置 ssh 一次,使用用户名和密码配置一次,但仍然遇到相同的错误,尝试删除该框并再次添加它,同样的问题

使用:- ubuntu 16.04 作为主要操作系统 Vagrant 1.9.4 虚拟盒:5.0.40 vagrantbox:便当/ubuntu-16.04 Vagrant 文件“使用密码 ssh”

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 key ”

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...

最佳答案

除非您创建了自己的帐户,否则您无法使用自己的用户名登录。公共(public)盒子的默认约定是创建一个 vagrant 用户,因此除非明确指定或者您已经使用特定用户创建了自己的盒子(例如通过打包程序),否则您需要使用 vagrant 用户登录。

删除您的config.ssh.usernameconfig.ssh.password或替换为vagrant用户,它会让您登录

关于linux - 即使在创建时,vagrant 也永远无法 ssh 到我的 ubuntu 盒子。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44488937/

相关文章:

c++ - 我有 libstdc++6-dev 但仍然有 STL 链接错误

ruby-on-rails - 无法在 Ubuntu 上使用 Rails

groovy - 如何从soapui groovy脚本执行shell脚本?

python - 如何使用 Python 的 Paramiko 模块 ssh 到需要两次密码身份验证的服务器?

ssh - 错误 : (gcloud. compute.ssh) 无法获取资源: - 权限不足

c++ - Linux 中对静态链接的误解

c - 内存分配错误 - 在 Linux 而不是 OSX Unix

linux - 如果标签之间是值,如何在 html 标签之间 grep/sed

arrays - 枚举具有给定名称的正在运行的进程数 - 分配给变量

bash - 如何在ubuntu中回显斜线