vagrant ssh always fails on exit status 255

1,101 views
Skip to first unread message

bart...@gmail.com

unread,
Mar 21, 2019, 10:07:04 AM3/21/19
to Vagrant
Recently Vagrant ssh stopped working and I can't figure out why. It's probably a local setting that's messed up, so that's why I'm posting here instead of on the Github bug tracker.

Software Versions:
Host OS: Win 10 Pro x64 with PowerShell
Guest OS: doesn't really matter
Vagrant: 2.2.4
Virtual Box: 5.2.26

To reproduce:
$ vagrant init ubuntu/cosmic64
$ vagrant up


Ends with:
==> 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
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.



When running ssh:

$ vagrant ssh --debug


DEBUG virtualbox_5_2:   - [1, "ssh", 2222, 22, "127.0.0.1"]
 INFO subprocess: Starting process: ["C:\\HashiCorp\\Vagrant\\embedded\\usr\\bin/ssh.EXE"]
DEBUG subprocess: Selecting on IO
DEBUG subprocess: stderr: usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-E log_file] [-e escape_char]
           [-F configfile] [-I pkcs11] [-i identity_file]
           [-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec]
           [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]
           [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
           [user@]hostname [command]
DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000
DEBUG subprocess: Exit status: 255
 INFO ssh: Invoking SSH: C:\HashiCorp\Vagrant\embedded\usr\bin/ssh.EXE ["vag...@127.0.0.1", "-p", "2222", "-o", "LogLevel=FATAL", "-o", "Compression=yes",
"-o", "DSAAuthentication=yes", "-o", "IdentitiesOnly=yes", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-i", "C:/Users/Bart/.vag
rant.d/insecure_private_key"]
DEBUG safe_exec: Converting command and arguments to common UTF-8 encoding for exec.
DEBUG safe_exec: Command: `"C:\\HashiCorp\\Vagrant\\embedded\\usr\\bin/ssh.EXE"` Args: `["vag...@127.0.0.1", "-p", "2222", "-o", "LogLevel=FATAL", "-o", "C
ompression=yes", "-o", "DSAAuthentication=yes", "-o", "IdentitiesOnly=yes", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-i", "C
:/Users/Bart/.vagrant.d/insecure_private_key"]`
DEBUG safe_exec: Converted - Command: `"C:\\HashiCorp\\Vagrant\\embedded\\usr\\bin/ssh.EXE"` Args: `["vag...@127.0.0.1", "-p", "2222", "-o", "LogLevel=FATA
L", "-o", "Compression=yes", "-o", "DSAAuthentication=yes", "-o", "IdentitiesOnly=yes", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/nul
l", "-i", "C:/Users/Bart/.vagrant.d/insecure_private_key"]`

When I open Virtual Box, the box runs without issues. I can show the GUI and log in the tty. It seems to be just ssh that's not working.

I've also tried:
- Uninstall and reinstall Vagrant
- Cleaned up environment vars (initially it was using git's ssh), now it's enforced with VAGRANT_PREFER_SYSTEM_BIN
- Checked if the ssh service was running in Ubuntu, and if I can ping the host OS. Both seems fine.

I've run out of ideas. Any other suggestions I could try?

Thanks!





Salty Vagrant

unread,
Mar 21, 2019, 11:02:10 AM3/21/19
to Vagrant

Have you tried SSH into the machine manually (using PuTTY or something similar)?

Is the machine a work work machine (I’m wondering if some new security policy could be blocking SSH), or possibly a Windows update has similarly affected a firewall/security setting?

Just some ideas.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/a9446a61-8dc2-4044-80e1-fac55835b5ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

bart...@gmail.com

unread,
Mar 22, 2019, 5:56:12 AM3/22/19
to Vagrant
Thanks Salty, I really appreciate that you take the time to help me out.

I tried:
- Disabling Windows firewall and Defender, no difference
- Alternative ssh client (MobaXTerm): couldn't connect, gave "Connection Refused" error
- Hard reset of Windows with `shutdown /r /f /t 0`m no difference

After some digging I found this error in the in the VBox log:
> 00:00:01.004256 NAT: Failed to redirect TCP 127.0.0.1:2222 -> 0.0.0.0:22 (Unknown error)
Unfortunately Vagrant is unaware that this redirection fails.

I then looked for processes that occupy this port with `netstat -an` but this wasn't the case.

Changing the port with`config.vm.network :forwarded_port, guest: 22, host: 22213, id: "ssh"` in the Vagrantfile works, luckily.
It's kind of odd though, I tried port 2223 first and that also failed.

Some other people had this issue too:

I'll try again with VBox v6 soon, maybe that works better now. I tried the upgrade when it was just released but ran into issues with Vagrant (invalid box state or something)  so I downgraded back to v5.2.




Op donderdag 21 maart 2019 16:02:10 UTC+1 schreef Salty Vagrant:

Alvaro Miranda Aguilera

unread,
Mar 25, 2019, 2:45:54 PM3/25/19
to vagra...@googlegroups.com
hello.

when the vagrant up command fails, check

the output of . vagrant ssh-config

vs whats in the the virtualbox , VM - > settings, network, port forwarding.

does match ?

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/a9446a61-8dc2-4044-80e1-fac55835b5ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Alvaro

bart...@gmail.com

unread,
Mar 26, 2019, 7:16:00 AM3/26/19
to Vagrant
Hi Alvaro,

Yes, the output of vagrant ssh-config matched with Vbox's port forwarding settings.

I think the root cause was really this VBox error while bringing it up:
> 00:00:01.004256 NAT: Failed to redirect TCP 127.0.0.1:2222 -> 0.0.0.0:22 (Unknown error)

So Vagrant was ok, VirtualBox just failed to forward the port.

Op maandag 25 maart 2019 19:45:54 UTC+1 schreef Alvaro Miranda Aguilera:
Reply all
Reply to author
Forward
0 new messages