首页 文章

不能ssh到新创建的流浪盒

提问于
浏览
0

刚创造了一个新的流浪盒,最小的数量为7 .

我按照这个指南 . 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和vagrant 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

3 回答

  • 0

    1.8.5中有一个错误可以解释这一点 .

    你能升级到1.8.6吗?

  • 0

    你尝试过使用过吗?

    vagrant ssh
    
  • 0

    这可能对某人有帮助 . 尝试运行 ip addr 命令,如果网络接口没有分配IP地址,则需要将 ONBOOT 设置为 yes .

    [root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
    

    然后将 ONBOOT=no 更改为 ONBOOT=yes 重新启动计算机并运行 ip addr 以确保正确启动网络并为网络接口分配IP地址 .

相关问题