The problem with ssh authentication:
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> 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: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Authentication failure. Retrying...
default: Error: Authentication failure. Retrying...
default: Error: Authentication failure. Retrying...
default: Error: Authentication failure. Retrying...
default: Error: Authentication failure. Retrying...
I can Ctrl+C
out of the authentication loop and then successfully ssh in manually.
I performed the following steps on the guest box:
Enabled
Remote Login
forAll Users
.Created the
~/.ssh
directory with0700
permissions.Created the
~/.ssh/authorized_keys
file with0600
permissions.Pasted this public key into
~/.ssh/authorized_keys
I've also tried using a private (hostonly) network instead of the public (bridged) network, using this line in the Vagrantfile:
config.vm.network "private_network", ip: "172.16.177.7"
I get the same output (except Adapter 2: hostonly
) but then cannot ssh in manually.
I also tried config.vm.network "private_network", ip: "10.0.0.100"
.
I also tried setting config.ssh.password
in the Vagrantfile. This does output SSH auth method: password
but still doesn't authenticate.
And I also tried rebuilding the box and rechecking all the above.
It looks like others have had success with this configuration, so there must be something I'm doing wrong.
I found this thread and enabled the GUI, but that doesn't help.
If you experience this issue on vagrant 1.8.5, then check out this thread on github:
https://github.com/mitchellh/vagrant/issues/7610
It's caused basically by a permission issue, the workaround is just
then
FYI: this issue only affects CentOS, Ubuntu works fine.
I have found a way around the mess with the keys on Win 8.2 where I did not succeed with any of the methods mentioned here. It may be interesting that exactly the same combination of VirtualBox, Vagrant, and the box run on Win 7 Ultimate without any problems.
I switched to the password authentication by adding the following commands in Vagrantfile:
Note that I'm not sure that this is the only changes required because I already did:
I generated a new RSA key pair and changed authorized_keys file accordingly (all in the virtual machine, see the suggestions above and elsewhere)
I copied the private key to the same directory where Vagrantfile resides and added
But I believe that these changes were irrelevant. I spent a plenty of time trying, so I did not change the working configuration by obvious reasons :)
None of the above worked for me. Somehow the box had the wrong public key added in the vagrant user authorised_keys file.
If you can still ssh on the box with the vagrant password (password is vagrant), i.e.
then copy the public key content from https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub to the authorised_keys file with the following command
When done exit the VM and try vagrant ssh again. It should work now.
In my experience, this has been a surprisingly frequent problem with new vagrant machines. By far the easiest way to solve it, instead of altering the configuration itself, has been creating the required ssh keys manually on the client, then using the private key on the host.
vagrant ssh
, use default passwordvagrant
.ssh-keygen -t rsa -b 4096 -C "vagrant"
(as adviced by GitHub's relevant guide).mv .ssh/id_rsa.pub .ssh/authorized_keys
.sudo service ssh reload
.cat .ssh/id_rsa
, paint and copy (better ways must exist, go invent one!).logout
.vagrant ssh-config
(look for instance ÌdentityFile "/[...]/private_key".nano /[...]/private_key
and paste from the clipboard, if all else fails. (Note, however, that if your private_key is not project specific but shared by multiple vagrant machines, you better configure the path yourself in order to not break other perfectly working machines! Changing the path is as simple as adding a lineconfig.ssh.private_key_path = "path/to/private_key"
into the Vagrantfile.) Furthermore, if you are using PuPHPet generated machine, you can store your private key to filepuphpet/files/dot/ssh/id_rsa
and it will be added to Vagrantfile's ssh config automatically.vagrant ssh
should now work.Should that be the case, congratulate yourself,
logout
, runvagrant provision
if needed and carry on with the meaningful task at hand.If you still face problems, it may come handy to add verbose flag to ssh command to ease debugging. You can pass that (or any other option, for that matter) after double dash. For example, typing
vagrant ssh -- -v
. Feel free to add as many v's as you need, each will give you more information.This can also happen if you're trying to force your VM to use a root user by default for SSH....
For example, a config like so in your Vagrantfile may cause this failure:
Solution: Comment out those lines and try again!
I have started the machine, then:
vagrant ssh-config
I've gotten the following:
Host default HostName 127.0.0.1 User vagrant Port 2222 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile /Users/my-user-name/Documents/PHP-Projects/my-php-project/puphpet/files/dot/ssh/id_rsa IdentityFile /Users/my-user-name/.vagrant.d/insecure_private_key IdentitiesOnly yes LogLevel FATAL
Then I've ran
cat ~/.ssh/id_rsa > /Users/my-user-name/Documents/PHP-Projects/my-php-project/puphpet/files/dot/ssh/id_rsa
Machine booted from here on