Vagrant ssh in Windows: ssh_exchange_identification - windows

So I'm writing guides to get vagrant working on all different operating systems, and I've saved the worst for last... Windows. I've installed virtualbox, vagrant, and a native ssh command line client so I can execute ssh servername successfully. I am also able to run vagrant up, and it brings up the machine (I can see in the VBox GUI), but hangs at "waiting for VM to boot. This can take a few minutes...".
Trying to run vagrant ssh from the command prompt yields an error, sure enough.
ssh_exchange_identification: Connection closed by remote host
I'm fairly new to networking, and I have no idea what is going wrong here. Is it an issue with the private key? (I have the paths for the private key configured properly), or is it a Windows network issue? I haven't been able to find the answer online yet and would appreciate some help. Thanks! A fix would be amazing.

You can try rebooting the machine with
vagrant reload (CTRL + C if it takes too long)
And then try
vagrant up
Now you should be able to ssh back in with
vagrant ssh

Related

No prompt ubuntu virtual machine using vagrant on Git Bash

After logging into the VM using vagrant ssh using GitBash on Windows 10, I don't see any directory prompts. While it does run the python web forum (for a tutorial on Udacity on Intro to Relational Databases), it won't let me run psql so I can continue the lesson. I can change directories, list information about the files, and run python but the prompt isn't working like normal.
Screenshot here: screenshot.
Please note the forum is running, this screenshot was taken after I exited and restarted vagrant.
Vagrant version 1.9.6
Ubuntu version 16.04.2 LTS
All programs installed or running in administrator mode.
I had the same problem attempting to set up Laravel Homestead - in my case it seems to be an issue with Git Bash / MINGW64.
My work-around was to use PuTTY
Install PuTTY, PuTTYgen
Create a .ppk of the key you're using to connect to the vagrant vm by loading the private key in PuTTYgen and saving the private key
Create a new PuTTY session with your vagrant details, in my case I just copied what was displayed after running "vagrant up" as far as SSH address, username (my PuTTY session Host Name would be "vagrant#localhost" port: 2222)
specify the ppk in the PuTTY configuration under Connection-> SSH-> Auth-> Private key for authentication
In short, try connecting with PuTTY or some other terminal emulator and see if you have any luck.
I wasn't able to get Git Bash to work, but the show window for the Oracle VM VirtualBox Manager does work just fine. I've been using Git Bash to start the VM, then switch to the Oracle VM UI window.
I had the same issue with truing to connect to a virtual Homestead session (Laravel) using virtual box and I was trying to connect via Gitbash MINGW64 as well.
I tried the same in cmd.exe (command: vagrant ssh) and it worked.
So should be issue with Git bash.

Error after `vagrant halt; vagrant up`

I am setting up a Ubuntu 15.04 VM on Win7 using Vagrant 1.7.4 and VBox 5.0.0.
On the first vagrant up I can ssh into the machine using vagrant putty and everything is setup correctly and works. When I run vagrant halt, the VM shuts down gracefully without error messages.
However, when I try to restart the VM using vagrant up; vagrant putty, the machine is in a strange state. For example, the default synced folder /vagrant is empty, even though the second vagrant up call prints this message:
default: /vagrant => C:/Users/ArneUser/numecs/dev_env
Also, this vagrant up call prints the following message in PowerShell:
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=
Stdout from the command:
Stderr from the command:
stdin: is not a tty
bash: line 2: /sbin/initctl: No such file or directory
I am running a really basic setup just to test for this error, so I don't think the mistake is in my provisioning script. Some pointers in the right direction would be appreciated.
Open VirtualBox GUI and turn off machine manually, then run again the vagrant up command.
That solved the problem in my case :)
/vagrant is empty
/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=
From these two lines I suspect that MOUNTPOINT should be /vagrant but its due to /vagrant being empty that SSH is now working.
I've seen similar issues because of Virtualbox 5.
Try to downgrade Virtualbox to 4.3.x and ensure you have the latest Vagrant (1.7.4).
https://github.com/mitchellh/vagrant/issues/5572
Initctl is part of the Upstart init daemon. As far as I'm aware Ubuntu 15.04 is the first version of Ubuntu to abandon Upstart in favor of SystemD, so /sbin/initctl isn't expected to exist in your operating system. I believe this would need to be something that is fixed in the box you're using.
The point of "/sbin/initctl emit ..." is to notify other Upstart units that the vagrant shared folder has been mounted and is available for read/write operations. Since upstart is no longer in use it may be safe to assume that there is no need for this call. It's a rather crude hack, but you could make an empty script at /sbin/initctl. This should allow the vagrant startup process to continue properly and provision your box.
In my case it seems as Marc Young suggested that by opening Virtualbox GUI, the virtual machine itself seems to be hung. I saw these error messages on the virtual box console:
Thus it seems to not to be Vagrant related problem, but the virtual machine (Linux Kernel) itself seems to be hung.

Running Vagrant 1.2.2 on VirtualBox in the Terminal would get the machine stuck in debian-login

I am currently setting up Vagrant 1.2.2 on my Mac OS X 10.9.2 using VirtualBox.
Using the command vagrant up under my dev/official directory, I would get this issue: VirtualBox would boot vagrant up, but it would be stuck on this screen:
Debian GNU/Linux 7 vagrant-debian tty1
vagrant-debian login:
When it times out, it will give me a SSH error.
This only happens when I boot the machine up via the Terminal, since with the GUI, I can put in the login credentials vagrant and vagrant for username and password respectively. I do not want to use the GUI; I want to use the Terminal to automatically log me into the machine.
What I tried is, I point vagrant to my private key using this within Vagrantfile:
Vagrant.configure("2") do |config|
config.ssh.private_key_path = "~/.ssh/github_rsa"
config.ssh.forward_agent = true
end
~/.ssh/github_rsa is the extension to my private key. When I check vagrant ssh-config, I noticed the IdentityFile points to IdentityFile "/Users/my_name/.vagrant.d/insecure_private_key", which is not the right private key. What I did to try to solve this issue was manually copy my github_rsa private key to that directory (and naming the old one to insecure_private_key_old). That did not solve an issue, and instead, actually gave me another issue:
/Applications/Vagrant/embedded/gems/gems/net-ssh-2.6.7/lib/net/ssh/key_factory.rb:77:inread': Could not parse PKey: no start line (ArgumentError)`
This is one of the many errors that popped up. Seems to be a gems issue.
I am not quite sure what the issue is, and if anyone of you have encountered this issue before, please let me know.
EDIT: I have tried to uninstall net-ssh and installing an older version of net-ssh as suggested by a thread I found online by the name "ArgumentError: Could not parse PKey: no start line", but that did not seem to help the issue either.

Vagrant Connection Refused Error

Virtual Box 4.3.14
Vagrant 1.6.3
and when I vagrant up I get this error
default: warning: connection refused. Retying...
it goes on and on until it gives up and says
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.
I am on windows 7, I even tried running cmd on administrator mode same thing
I even tried vagrant reload as I read on on other web resources, still same thing, it outputs the same thing
I did not tweak my virtualbox after install, basically just install virtualbox and install vagrant then run vagrant up
and oh by the way my vagrantfile and provisioning script is from here
https://gist.github.com/JeffreyWay/9244801
https://gist.github.com/JeffreyWay/9244714
Been googling and unfurtunately I can't find clear answer
Tnx in advance
It seems its a virtual box / vagrant version incompatibility issue
I uninstalled Virtual Box 4.3.14 and installed Virtual Box 4.3.12 and it worked. Basically I downgraded virtual box.
I hope this gets fixed soon.
Hope this helps anyone.
Open your vagrantfile using notepad and edit it so that it looks like this:
Please tally your vagrantfile with this one word by word. Then open BIOS and turn on virtualisation. Watch this video to learn how to do it. It is a very short video.
PS: You may need to uninstall vagrant before doing this. And in your Users folder in C:, there will be a folder named .vagrant.d, please delete that as well before following these steps.
Uninstalling vagrant will require that you run your machine as administrator. You can right click on Command Prompt (search cmd in windows search box) and click run as administrator. Type the following command: net user administrator /active:yes
You will get a message called command completed successfully. Now you can log off and see that there are two accounts, one of them is admin. You can log in from that and uninstall vagrant.

How to SSH into a local Ubuntu Server with Mac terminal?

I have been a Windows user all my life and I just got a Mac recently. With Windows (puTTY), I have "SSHed" into a local Ubuntu Server dozens of times in the past. I attempted to perform the same steps with my Mac, but I am not able to make any significant progress. Can anyone provide a guide as to how to SSH into a local Ubuntu Server?
I have a clean installation of Ubuntu Server running right now. Here is a picture of when I do "ifconfig":
The steps that I have done previously are as follows:
Install openSSH Server
In terminal, "ssh anish#localhost"
Connection is timed out or my password is not accepted.
Change it to bridged in ur VM settings in virtual box and use ssh anish#inet

Resources