2017-03-17 109 views
0

我有一个Ubuntu 16.04 LTS和三个流浪汉/ VirtualBox的虚拟机需要在同一时间流浪SSH连接失败

当我在VirtualBox中,第一天装流浪汉被打开,SSH连接正想正确。在接下来的一天,我得到这个在三台机器(这里是其中的一个示例):

[email protected]:~/VM$ vagrant up vvs --provision 
Bringing machine 'vvs' up with 'virtualbox' provider... 
==> vvs: Checking if box 'dmservices/fedora17-x86_64' is up to date... 
==> vvs: Clearing any previously set forwarded ports... 
==> vvs: Clearing any previously set network interfaces... 
==> vvs: Preparing network interfaces based on configuration... 
    vvs: Adapter 1: nat 
    vvs: Adapter 2: hostonly 
==> vvs: Forwarding ports... 
    vvs: 22 (guest) => 2222 (host) (adapter 1) 
==> vvs: Running 'pre-boot' VM customizations... 
==> vvs: Booting VM... 
==> vvs: Waiting for machine to boot. This may take a few minutes... 
    vvs: SSH address: 127.0.0.1:2222 
    vvs: SSH username: vagrant 
    vvs: SSH auth method: password 
    vvs: Warning: Remote connection disconnect. Retrying... 
    vvs: Warning: Authentication failure. Retrying... 

,直到触发超时

当我尝试vagrant ssh vvs,有或没有--plain

==> vvs: The machine you're attempting to SSH into is configured to use 
==> vvs: password-based authentication. Vagrant can't script entering the 
==> vvs: password for you. If you're prompted for a password, please enter 
==> vvs: the same password you have configured in the Vagrantfile. 
Permission denied (publickey). 

此所述Vagrantfile的该机器(三台机器之间的唯一差别是名称,IP(在同一网络192.168.33.0/24内的部分),而其他两个是的Debian/jessie64):

Vagrant.configure("2") do |config| 
    ... 
    ... 
    config.vm.define "vvs" do |vvs| 
     vvs.vm.hostname = "vvs" 
     vvs.vm.box = "dmservices/fedora17-x86_64" 
     vvs.vm.network "private_network", ip: "192.168.33.4" 
     vvs.ssh.username = "vagrant" 
     vvs.ssh.password = "vagrant" 
     vvs.vm.synced_folder "/home/xxxx-callserver/NetBeansProjects", "/NetBeansProjects", create: true, type: "virtualbox" 
     vvs.vm.provider "virtualbox" do |v| 
      v.memory = 2048 
      v.cpus = 2 
      v.customize ["modifyvm", :id, "--vram", "64"] 
    end 
end 

在此先感谢,如果需要

编辑问我要更多的信息:输出流浪汉SSH-Config的

Host avaya 
    HostName 127.0.0.1 
    User vagrant 
    Port 2201 
    UserKnownHostsFile /dev/null 
    StrictHostKeyChecking no 
    PasswordAuthentication no 
    IdentityFile /home/xxxx-callserver/VM/.vagrant/machines/avaya/virtualbox/private_key 
    IdentitiesOnly yes 
    LogLevel FATAL 

Host videogateway 
    HostName 127.0.0.1 
    User vagrant 
    Port 2200 
    UserKnownHostsFile /dev/null 
    StrictHostKeyChecking no 
    PasswordAuthentication no 
    IdentityFile /home/xxxx-callserver/VM/.vagrant/machines/videogateway/virtualbox/private_key 
    IdentitiesOnly yes 
    LogLevel FATAL 

Host vvs 
    HostName 127.0.0.1 
    User vagrant 
    Port 2222 
    UserKnownHostsFile /dev/null 
    StrictHostKeyChecking no 
    PasswordAuthentication no 
    IdentitiesOnly yes 
    LogLevel FATAL 
+0

你能够使用ssh直接访问该IP(使用相同的凭据吗?你能够通过Virtualbox GUI以这些凭证登录吗?流浪ssh-config的输出是什么? –

+0

@GonzaloMatheu编辑ssh -config。是的,我可以访问操作系统,就像我使用的只是普通的VirtualBox –

+0

而且你能够使用ssh连接ssh -p 2222 UserKnownHostsFile =/dev/null vagrant @ 127.0.0.1'或'ssh - p 2200 UserKnownHostsFile =/dev/null -i /home/xxxx-callserver/VM/.vagrant/machines/videogateway/virtualbox/private_key vagrant @ 127.0.0.1'? –

回答

0

请检查您是否明确转发每个流浪客人端口22到不同的主机端口。我不熟悉vagrant脚本,但是您确实需要一行来显式指定不同的端口,因为默认的Vagrant总是映射22到2222.对于多个VM。这意味着只有第一个流浪者虚拟机会将其映射为正确的,其余的将失败。在Vagrantfile中,每个访客机器都需要这样的东西。

# avaya 
config.vm.network :forwarded_port, id: 'ssh', guest:22, host: 2201, 

# videogateway 
config.vm.network :forwarded_port, id: 'ssh', guest:22, host: 2200, 

# vvs 
config.vm.network :forwarded_port, id: 'ssh', guest:22, host: 2222, 

既然你已经有了第一个虚拟机的设置,从22端口转发到2222,所有的3 VM会失败的更改端口转发地图。也许你应该考虑更改主机vvs转发到不同的主机端口,所以它不会与使用默认电源转发的未来adhoc vagrant启动相冲突。

+0

我只打开一个虚拟机('vvs')'vvs.vm.network“forwarded_port”,id:“ssh”,guest:22,host:2201' in the Vagrantfile('videogateway'有2202,'avaya'有2200),它继续循环到'vvs:Warning:Authentication failure。重试......直到超时 –