Whenever I try to connect to my local Vagrant, I get this error when I run ssh vagrant@127.0.0.1:2222
from the Windows git bash:
ssh: connect to host 127.0.0.1:2222 port 22: Bad file number
It was working previously, so I'm not sure what could have caused this. When I try to do an SFTP connection in PHPStorm 8, I get this error:
Connection to '127.0.0.1' failed.
SSH_MSG_DISCONNECT: 2 Too many authentication failures for vagrant
I've tried vagrant destroy
with vagrant box remove laravel/homestead
and then recreating the box from a backup I had that previously worked using vagrant box add laravel/homestead homestead.box
but I still get the same errors.
I'm on Windows 7.
What can I do to get access to my vagrant box commandline again?
The answer by outboundexplorer above is the correct one I believe.
Here is my step-by-step approach on how I did this:
Step 1: Find out exactly what SSH settings to use
Ensure the vagrant box is running (you've done
vagrant up
that is)From the command line, go to your project directory (the one where the Vagrantfile is located) and run
vagrant ssh-config
.You'll get an output like this:
Step 2: Setting up PHPStorm to SFTP to the Vagrant box
Based on the config settings shown above, I set up the following SFTP remote deployment server:
/home/ubuntu/my-test-project
(this is the folder inside the Vagrant box where the files will be uploaded to, change to whatever suits your needs)IdentityFile
path shown (C:/Projects/....)... and that was it.
Try command:
ssh -p 2222 vagrant@127.0.0.1
Make sure your vagrant is up and running by command : vagrant up
and then do vagrant ssh. It will connect to vagrant localhost
I got this same failure when using PHpStorm to SSH into the VirtualBox guest machine that i had set up with Vagrant. Everything worked fine before I upgraded to Windows 10. After upgrading, first of all i had to upgrade to VirtualBox and Vagrant latest versions to get everything to work on Windows 10.
But then i couldn't ssh into the guest machine using the PhpStorm ssh client. After much reading, everything seemed to suggest that I had too many ssh-keys installed on my Windows machine, but checking
regedit
just showed that I only had a couple of keys which should be less than the suggested max 5 keys (as default). In the end i didvagrant ssh
which didn't allow me to ssh into the guest machine, but it did reconfirm the ssh details for me. I then realized that after all the new installs it didn't want me to use theC:\Users\Andy\.vagrant.d\insecure_private_key
key but instead use a key that it had placed within the project itself atC:/Users/Andy/CodeLab5/vagrant/.vagrant/machines/default/virtualbox/private_key
.Everything is working as it should again now :)