[英]Vagrant SSH connection failure
我有一個Ubuntu 16.04 LTS和三個需要同時打開的Vagrant / VirtualBox VM
當我將Vagrant與VirtualBox一起安裝時,第一天,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...
直到觸發超時
當我嘗試使用或不使用--plain
來使vagrant ssh vvs
時:
==> 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
請檢查您是否將每個Vagrant來賓端口22明確轉發到其他主機端口。 我不熟悉vagrant腳本,但是您確實需要一行來顯式指定其他端口,因為默認的Vagrant始終將22映射到2222。對於多個VM。 這意味着只有第一個無用的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個虛擬機都將無法更改端口轉發映射。 也許您應該考慮將主機vvs
轉發更改為不同的主機端口,這樣就不會與以后使用默認電源轉發的即席無用的啟動有關。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.