OSX 上的 Vagrant 1.7 SSH 身份验证失败 – 私钥未复制到 VM
Vagrant 1.7 SSH authentication failure on OSX – private key not copied to VM
首先,我知道这是一个重复的问题,但我与这个问题斗争了大约 20 个小时,因为 none 其他问题的答案对我有用。这是 Mac OS X 具体的问答。虚拟提供商是 VirtualBox 4.3 和 5.0。 Vagrant 版本 1.7.1 和 1.7.4
此 SSH 身份验证失败不断发生。如果我等待或退出进程,我可以 "vagrant ssh" 没有问题,使用默认密码 "vagrant"。但是由于发生了这个SSH失败,这意味着启动后的脚本也没有执行。
vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'laravel/homestead'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: Setting the name of the VM: homestead
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 80 => 8000 (adapter 1)
default: 443 => 44300 (adapter 1)
default: 3306 => 33060 (adapter 1)
default: 5432 => 54320 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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
default: Warning: Connection timeout. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
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.
Vag运行t 1.7 将此默认配置设置为 true:config.ssh.insert_key
Vag运行t 将自动插入用于 SSH 的密钥对,如果检测到,将替换默认的 Vag运行t 机器内部的不安全密钥。 link to Vagrant SSH settings
当 vag运行t up 我做了 vag运行t ssh-config 我可以看到私钥路径是 ~/.vag运行t.d/insecure_key – 但该密钥也没有复制到 VM 内部。
问题在于我不知何故弄乱了 OS X 的 SSH 配置。当我 运行 命令 ssh-add -l 列出 SSH 代理中加载的密钥时,这一点很明显。有两个具有相同路径的不同键!但是我无法确认这是问题的主要原因,因为它已经持续了好几天并且在此期间我进行了几次重新启动。
我备份了 .ssh 文件夹,并一个一个地复制了旧的配置行和文件。我做的另一件事是删除此 ill-advised tip 以在 ~/.ssh/config
中添加此行
Host *
ForwardAgent yes
这种做法是strongly recommended against by Github:
警告:您可能会想使用像 Host * 这样的通配符来将此设置应用于所有 SSH 连接。这并不是一个好主意,因为您将与 SSH 连接到的每台服务器共享本地 SSH 密钥。他们无法直接访问密钥,但在建立连接后,他们将能够像您一样使用密钥。您应该只添加您信任的服务器以及您打算用于代理转发的服务器。
在执行这些步骤之前,我清空了 ~/.vagrant.d 文件夹,以确保我之前没有设置全局配置。您也可以使用他们的卸载脚本卸载 Vag运行t,然后重新安装。
已重新启动。然后我创建了一个新的 SSH 密钥。
然后vag运行t provision or vag运行t destroy && vag运行t up. 这就是我最终解决这个问题的方法!
我的解决方案是在 Vagrant 显示时 'default: Warning: Authentication failure. Retrying...'
在我的本地机器上获取 public ssh 密钥并将其粘贴到 ~/.ssh/authorized_keys 中的 vagrant 中。在我的案例中,这让 vagrant 可以无缝地进入 ssh 并继续进行配置。希望我知道是什么导致了挂起。 (在发布 vagrant up 之前,我还删除了现有 .vagrant 和 .vagrant.d 文件夹的所有痕迹。)
cat ~/.ssh/id_rsa.pub
vagrant ssh
echo 'your-public key' >> ~/.ssh/authorized_keys (or paste it in by hand so you don't accidentally delete any existing keys)
首先,我知道这是一个重复的问题,但我与这个问题斗争了大约 20 个小时,因为 none 其他问题的答案对我有用。这是 Mac OS X 具体的问答。虚拟提供商是 VirtualBox 4.3 和 5.0。 Vagrant 版本 1.7.1 和 1.7.4
此 SSH 身份验证失败不断发生。如果我等待或退出进程,我可以 "vagrant ssh" 没有问题,使用默认密码 "vagrant"。但是由于发生了这个SSH失败,这意味着启动后的脚本也没有执行。
vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'laravel/homestead'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: Setting the name of the VM: homestead
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 80 => 8000 (adapter 1)
default: 443 => 44300 (adapter 1)
default: 3306 => 33060 (adapter 1)
default: 5432 => 54320 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> 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
default: Warning: Connection timeout. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
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.
Vag运行t 1.7 将此默认配置设置为 true:config.ssh.insert_key
Vag运行t 将自动插入用于 SSH 的密钥对,如果检测到,将替换默认的 Vag运行t 机器内部的不安全密钥。 link to Vagrant SSH settings
当 vag运行t up 我做了 vag运行t ssh-config 我可以看到私钥路径是 ~/.vag运行t.d/insecure_key – 但该密钥也没有复制到 VM 内部。
问题在于我不知何故弄乱了 OS X 的 SSH 配置。当我 运行 命令 ssh-add -l 列出 SSH 代理中加载的密钥时,这一点很明显。有两个具有相同路径的不同键!但是我无法确认这是问题的主要原因,因为它已经持续了好几天并且在此期间我进行了几次重新启动。
我备份了 .ssh 文件夹,并一个一个地复制了旧的配置行和文件。我做的另一件事是删除此 ill-advised tip 以在 ~/.ssh/config
中添加此行Host *
ForwardAgent yes
这种做法是strongly recommended against by Github:
警告:您可能会想使用像 Host * 这样的通配符来将此设置应用于所有 SSH 连接。这并不是一个好主意,因为您将与 SSH 连接到的每台服务器共享本地 SSH 密钥。他们无法直接访问密钥,但在建立连接后,他们将能够像您一样使用密钥。您应该只添加您信任的服务器以及您打算用于代理转发的服务器。
在执行这些步骤之前,我清空了 ~/.vagrant.d 文件夹,以确保我之前没有设置全局配置。您也可以使用他们的卸载脚本卸载 Vag运行t,然后重新安装。
已重新启动。然后我创建了一个新的 SSH 密钥。
然后vag运行t provision or vag运行t destroy && vag运行t up. 这就是我最终解决这个问题的方法!
我的解决方案是在 Vagrant 显示时 'default: Warning: Authentication failure. Retrying...'
在我的本地机器上获取 public ssh 密钥并将其粘贴到 ~/.ssh/authorized_keys 中的 vagrant 中。在我的案例中,这让 vagrant 可以无缝地进入 ssh 并继续进行配置。希望我知道是什么导致了挂起。 (在发布 vagrant up 之前,我还删除了现有 .vagrant 和 .vagrant.d 文件夹的所有痕迹。)
cat ~/.ssh/id_rsa.pub
vagrant ssh
echo 'your-public key' >> ~/.ssh/authorized_keys (or paste it in by hand so you don't accidentally delete any existing keys)