2017-02-21 85 views
0

,當我在我的應用程序運行vagrant up過程中被卡在SSH和流浪

SSH auth method: private key 

Vagrantfile

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 

當在另一個窗口

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 

將在什麼地方insecure_private_key運行vagrant ssh-config來自?並應該不是私鑰

我可以看看什麼來嘗試和調試呢?我運行在調試模式vagrant,並發現這

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"] 

有沒有人有什麼進一步的想法,我可以做什麼?

感謝

回答

0

您在/Users/rich/.vagrant.d/insecure_private_key看到由無業遊民產生,如果ssh.insert_key屬性設置爲true的私鑰。

Looking at the documentation,您應該可以使用指定現有私鑰的位置。

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. 
+0

我很感激我的更新問題,你的答案後,但我有'app_config.ssh.insert_key = TRUE;在我的配置應該替換這個關鍵 – Richlewis

+0

我不敢肯定我明白你的問題。通過將其設置爲true,您會告訴流浪者生成自己的密鑰。 –

0

通常情況下,流浪會自動使用一個公共的,「知名」 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"