【发布时间】:2017-03-21 16:32:21
【问题描述】:
我有一个 Ubuntu 16.04 LTS 和三个 Vagrant/VirtualBox 虚拟机需要同时打开
当我用 VirtualBox 安装 Vagrant 时,第一天,SSH 连接正常。第二天我在三台机器上得到了这个(这里是其中一台的例子):
xxxx-callserver@xxxxcallserver-Precision-WorkStation-T5400:~/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
提前致谢,如果需要,请向我询问更多信息
编辑: vagrant 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
【问题讨论】:
-
您是否可以使用 ssh 直接访问该 IP(使用相同的凭据?您是否可以通过 Virtualbox GUI 使用这些凭据登录?
vagrant ssh-config的输出是什么? -
@GonzaloMatheu 编辑了 ssh 配置。是的,我可以像使用普通的 VirtualBox 一样访问操作系统
-
您可以使用 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进行连接吗? -
你是把 3 台 vagrant VM 放在同一台电脑还是 3 台不同的电脑上?
-
@GonzaloMatheu 给出以下错误
ssh: Could not resolve hostname userknownhostsfile=/dev/null: Name or service not known
标签: ssh vagrant virtualbox