Vagrant卡住连接超时重试(服务器拒绝我们的密钥)

时间:2016-07-26 08:27:26

标签: ssh vagrant virtualbox

昨晚我的流浪汉工作得非常好。我刚打开电脑,打开流浪汉,这就是我得到的:

vagrant up                                                                     
Bringing machine 'machine1' up with 'virtualbox' provider...                     
==> machine1: Checking if box 'puphpet/ubuntu1404-x64' is up to date...          
==> machine1: Clearing any previously set forwarded ports...                     
==> machine1: Clearing any previously set network interfaces...                  
==> machine1: Preparing network interfaces based on configuration...             
    machine1: Adapter 1: nat                                                     
    machine1: Adapter 2: hostonly                                                
==> machine1: Forwarding ports...                                                
    machine1: 22 (guest) => 9180 (host) (adapter 1)                              
    machine1: 22 (guest) => 2222 (host) (adapter 1)                              
==> machine1: Running 'pre-boot' VM customizations...                            
==> machine1: Booting VM...                                                      
==> machine1: Waiting for machine to boot. This may take a few minutes...        
machine1: SSH address: 127.0.0.1:2222                                        
machine1: SSH username: vagrant                                              
machine1: SSH auth method: private key                                       
machine1: Warning: Remote connection disconnect. Retrying...                 
machine1: Warning: Remote connection disconnect. Retrying...                 
machine1: Warning: Authentication failure. Retrying...                       
machine1: Warning: Authentication failure. Retrying...                       
machine1: Warning: Authentication failure. Retrying...                       
machine1: Warning: Authentication failure. Retrying...                       
machine1: Warning: Authentication failure. Retrying...                       
machine1: Warning: Authentication failure. Retrying...                       
machine1: Warning: Authentication failure. Retrying...                       
machine1: Warning: Authentication failure. Retrying...                       

当我尝试连接时,我看到了:

Using username "vagrant".
Server refused our key
vagrant@127.0.0.1's password:

但我的密钥文件没有改变。有类似的问题Vagrant stuck connection timeout retrying,但还有其他原因,但它对我没有帮助。

有ssh-config

> vagrant ssh-config                                              
Host machine1                                                     
HostName 127.0.0.1                                              
User vagrant                                                       
Port 2222                                                       
UserKnownHostsFile /dev/null                                    
StrictHostKeyChecking no                                        
PasswordAuthentication no                                       
IdentityFile "C:/puphpet/puphpet/files/dot/ssh/id_rsa"          
IdentityFile "C:/Users/alexk/.vagrant.d/insecure_private_key"   
IdentitiesOnly yes                                              
LogLevel FATAL                                                  

1 个答案:

答案 0 :(得分:1)

将以下代码行添加到C:\HashiCorp\vagrant\embedded\gems\gems\vagrant-1.8.5\plugins\guests\linux\cap\public_key.rb

chmod 0600 ~/.ssh/authorized_keys

原始版块 if test -f ~/.ssh/authorized_keys; then grep -v -x -f '#{remote_path}' ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmp mv ~/.ssh/authorized_keys.tmp ~/.ssh/authorized_keys fi

新区块: if test -f ~/.ssh/authorized_keys; then grep -v -x -f '#{remote_path}' ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmp mv ~/.ssh/authorized_keys.tmp ~/.ssh/authorized_keys chmod 0600 ~/.ssh/authorized_keys fi

我遇到了同样的问题并找到了上述解决方案here