2016-09-30 48 views
0

剛剛創建了一個最小的centos 7的新vagrant盒。不能ssh到新創建的流浪盒

我遵循本指南。 https://blog.engineyard.com/2014/building-a-vagrant-box

我也有到位的一切,在官方流浪者提到的導向件herehere

然而,當我嘗試做無業遊民了。它試圖ssh到盒子時超時。

什麼可能導致這種情況? VM中的我的網絡適配器是NAT。 我試圖設置私網IP

config.vm.network "private_network", ip: "192.168.50.4" 

我能夠使用此IP和流浪漢的用戶名和密碼爲SSH。我想知道爲什麼流浪漢不能ssh? 這裏是vagrant up

Bringing machine 'default' up with 'virtualbox' provider... 
==> default: Importing base box 'my'... 
==> default: Matching MAC address for NAT networking... 
==> default: Setting the name of the VM: my_box_default_1475351710988_24744 
==> default: Clearing any previously set network interfaces... 
==> default: Preparing network interfaces based on configuration... 
    default: Adapter 1: nat 
==> default: Forwarding ports... 
    default: 22 (guest) => 2222 (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:2222 
    default: SSH username: vagrant 
    default: SSH auth method: private key 

輸出,並且很長一段時間後,給出了這樣的錯誤。

Timed out while waiting for the machine to boot. This means that 
Vagrant was unable to communicate with the guest machine within 
the configured ("config.vm.boot_timeout" value) time period. 

If you look above, you should be able to see the error(s) that 
Vagrant had when attempting to connect to the machine. These errors 
are usually good hints as to what may be wrong. 

If you're using a custom box, make sure that networking is properly 
working and you're able to connect to the machine. It is a common 
problem that networking isn't setup properly in these boxes. 
Verify that authentication configurations are also setup properly, 
as well. 

If the box appears to be booting properly, you may want to increase 
the timeout ("config.vm.boot_timeout") value. 

SSH密鑰使用以下命令

mkdir -p /home/vagrant/.ssh 
chmod 0700 /home/vagrant/.ssh 
wget --no-check-certificate https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys 
chmod 0600 /home/vagrant/.ssh/authorized_keys 
chown -R vagrant:vagrant /home/vagrant/.ssh 

回答

0

這可能幫助別人。 嘗試運行ip addr命令,如果網絡接口沒有分配IP地址,則需要將ONBOOT設置爲yes

[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3 

然後換ONBOOT=noONBOOT=yes 重新啓動計算機並運行ip addr,以確保網絡的正常啓動和IP地址分配給網絡接口。

0

有在1.8.5中的錯誤可以解釋這個設置。

請問您可以升級到1.8.6嗎?

+0

我升級到1.8.6。重建盒子。但同樣的問題。 – kausar

+0

您可以在創建vagrant用戶的位置共享腳本,並在添加authorized_keys之後在ssh目錄中設置權限? – kikitux

+0

我將這些命令添加到問題中。只是爲了讓你知道我也試着用ssh使用密碼。 – kausar

1

您是否嘗試過使用

vagrant ssh