Alex
Alex

Reputation: 8072

Vagrant stuck connection timeout retrying (Server refused our key)

My vagrant was working perfectly fine last night. I've just turned the PC on, hit vagrant up, and this is what I get:

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

When I tried to connect I see this:

Using username "vagrant".
Server refused our key
[email protected]'s password:

But my key file didn't change. There is similar question Vagrant stuck connection timeout retrying but there is other reason and it not helped me.

There is 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                                                  

Upvotes: 0

Views: 3421

Answers (1)

Stigly
Stigly

Reputation: 171

Add the following line of code to C:\HashiCorp\vagrant\embedded\gems\gems\vagrant-1.8.5\plugins\guests\linux\cap\public_key.rb:

chmod 0600 ~/.ssh/authorized_keys


Original block: 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

New block: 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

I had the same problem and found the above solution here.

Upvotes: 1

Related Questions