当我在我的应用程序中运行
vagrant up
时,进程卡在
SSH auth method: private key
流浪者文件
Vagrant.configure(2) do |config|
config.vm.define :touch_rugby do |app_config|
app_config.vm.box = "bento/ubuntu-16.04"
app_config.vm.host_name = "touchrugby"
app_config.vm.network "private_network", ip: "33.32.1.2"
app_config.ssh.insert_key = true
end
end
在另一个窗口中运行
vagrant ssh-config
时
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /Users/rich/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
不安全的私钥从哪里来?它不应该是私钥吗?
我可以看什么来尝试调试这个?我在调试模式下运行
vagrant up
并发现了这个
INFO ssh: Attempting to connect to SSH...
INFO ssh: - Host: 127.0.0.1
INFO ssh: - Port: 2222
INFO ssh: - Username: vagrant
INFO ssh: - Password? false
INFO ssh: - Key Path: ["/Users/rich/.vagrant.d/insecure_private_key"]
DEBUG ssh: - connect_opts: {:auth_methods=> ["none "hostbased""publickey"],
:config=>false,
:forward_agent=>false,
:send_env=>false,
:keys_only=>true,
:paranoid=>false,
:password=>nil,
:port=>2222,
:timeout=>15 }
INFO subprocess: Starting process: ["/usr/local/bin/VBoxManage", "showvminfo", "1f000e35-eee4-482d-8f76-91082f19c2ab", "--machinereadable"]
如果
/Users/rich/.vagrant.d/insecure_private_key
属性设置为 true,则您在 ssh.insert_key
处看到的私钥是由 vagrant 生成的。
查看文档,您应该能够使用指定现有私钥的位置。
config.ssh.private_key_path
The path to the private key to use to SSH into the guest machine. By default this is the insecure private key that ships with Vagrant, since that is what public boxes use. If you make your own custom box with a custom SSH key, this should point to that private key.
通常,Vagrant 将自动使用公共的、“众所周知的”ssh 密钥,并自动将虚拟框设置为使用该密钥。要获得这种行为,只需不要在 Vagrantfile 中设置
app_config.ssh.insert_key = true
选项即可。
我们在 Vagrantfile 中设置这两个选项,因为我们不使用默认的
vagrant
帐户,但为了更好地模拟我们的 AWS 环境,我们创建了一个 ec2-user
帐户并指定我们自己的私有 ssh 密钥。
config.ssh.username = "ec2-user"
config.ssh.private_key_path = "/Users/lance/git/devops/.vagrant_helpers/vagrant_private_key"