vagrant ssh not working in MobaXterm on Windows - ruby

I have already found "SSH to Vagrant box in Windows" and added the git bin directory to my windows PATH. I verified that it worked by starting CMD and typing ssh, and got a usage message. (Before adding the git bin directory to my path, CMD complained that ssh wasn't a valid command.)
However...when I run vagrant ssh from MobaXterm, I get the same error I did before. (A page full of ruby errors that aren't helpful to me.) When I run it as VAGRANT_LOG=debug vagrant ssh, I see:
INFO subprocess: Starting process: ["C:\\Users\\(myname)\\DOCUME~1\\MOBAXT~1\\slash\\bin/ssh.EXE"]
This is the wrong ssh executable; it's the one installed in MobaXterm and it doesn't work if run from a CMD window.
How can I get vagrant ssh to work as it should?

Part of the trick is that I don't want to use the Windows PATH for arbitrary commands—not even for ssh, really. I want to use the versions in MobaXterm for everything. All I want is to be able to run vagrant ssh the same way I would on Linux or Mac.
The workaround I have been using, which I found somewhere online (but can't find the page again), is:
vagrant ssh-config > vagrant-ssh
ssh -F vagrant-ssh default # Works exactly the way `vagrant ssh` should
"default" is the box name for a typical Vagrant environment with only a single vagrant box. If there is more than one box, replace "default" with the box name:
ssh -F vagrant-ssh host001 # Works the way `vagrant ssh host001` would on another system
This is a good workaround with minimal changes required to workflow. But I'd still like a way to get vagrant ssh working without needing the extra file in my vagrant directory.

here you can find an explanation
In the documentation, this mention is in the "Terminal tab settings"
section, so you will find this option in the "Terminal" tab.
Go to MobaXterm global settings window, then click on the "Terminal"
tab and check the "Use Windows PATH environment". Note that if you are
using a session, you will have to do the same in this session: edit
your session, then go to the "Terminal settings" tab and check the
"Use Windows PATH" option.

Call me crazy but what about doing this:
Setup Vagrant Virtualbox VM like normal
In MobaXterm, create a "Bash" shell integration with the working directory setup as the directory of the Vagrant directory for the specific VM you are doing this for (aka ... the directory where the Vagrantfile lives for this VM)
In the "Advance Shell Settings", use this command (adjust vagrant path to where ever your Vagrant is installed as MobaXterm bash sees it):
command /drives/c/HashiCorp/Vagrant/bin/vagrant ssh-config >
vagrant-ssh-config && ssh -A -F vagrant-ssh-config default
Vagrant VM needs to be up for MobaXterm Bash entry for the VM to work. I just setup two Bash shell settings for two Vagrant Virtualbox VMs I created and it seems to work just fine.
Updated: I went a little further since I've figured this out .. at least for me I did :). I added additional CMD shell sessions MobaXterm for each of my Vagrant VM. These additional CMD shell sessions do Vagrant halt, up, and restart (combo of halt and up) commands against the VMs they are specific to. This is what restart looks like:
vagrant halt
vagrant up
set /p value="Press Enter to continue"
exit
The Startup Directory for the above session is, again, the directory where the Vagrantfile lives for this VM. Oh, and make sure that "Use Windows PATH" is checked in Terminal Settings.

you can install git (https://git-scm.com/downloads) during install git choose "use git and optional Unix tools from the windows command prompt"

Download msysgit from msysgit project page and include msysgit/bin folder to PATH, now you can run ssh and vagrant ssh form your terminal on windows.

Related

Vagrant ssh into a Windows 10 guest: PATH does not include tools provisioned with Chocolatey

We are running a Windows 10 Vagrant box, for which we made the base box with Packer.
The host is macOS 10.14.5
During Vagrant provisioning, we user Chocolatey to install different build tools we need.
Yet, if we vagrant ssh into the running box, we don't have access to these tools. Inspecting the PATH, it appears that it does not contain the directory for said tools.
Yet, if we run the box with its UI, and we log-in in the VM UI and launch "cmd.exe" from the start menu, then the PATH contains all the entries installed by Chocolatey.
What do we have to do to ensure the PATH is correct for vagrant ssh?
EDIT: Running vagrant winrm -c "echo \$env:PATH" does display the correct PATH

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.

Issue with setting up Vagrant

I have just set up a new Linux box and trying to install vagrant on it. The issue is that when I am running vagrant up command, I am getting the following error:
Vagrant failed to initialize at a very early stage:
The directory Vagrant will use to store local environment-specific
state is not accessible. The directory specified as the local data
directory must be both readable and writable for the user that is
running Vagrant.
Any idea how to fix this?
I think a better way is to provide your user the required permission to the directory by making the user the owner - where you want the vagrant to be booted:
$ sudo chown -R <user> <directory>
and then you will be easily able to do:
$ vagrant up
Using sudo for vagrant up is unusual as why do you want to run your virtual machine as a root user.
I met the same problem and I solved it by run the terminal with"run as administrator". It's quite easy.
Hope this can help you.
I encountered the same issue four years later and could not fix it using chmod or even #Ziya's comment under the initial question (which brought me closer to the resolution though).
In my case, I use Vagrant 2.2.6 on Windows 10, and use Cygwin as a command line interface.
For the error to disappear, I had to :
open Windows Explorer
right-click .vagrant folder in the location where I typed vagrant up
access the "Properties" menu
then, in the "Security" tab, update the authorizations for my user, granting total control
Properties window screenshot
Hope this can help someone else.
Please follow these steps:
1) install vagrant 1.7.1
2) install virtual box 4.1, 4.2, or 4.3
3) use the administrator name in the custom directory (e.g., for windows users c:\users\AdminName\myvagrant or for Mac/Linux users /home/Admin/myvagrant)
For instance: c:\users\safwan\myvagrant where safwan is the user with administrator rights/privileges.
Copy the file name Vagrantfile in the myvagrant forlder.
4) Now open DOS window as shown in the picture and follow the steps in the DOS window changing the admin name

windows os: vagrant ssh dont' work with git

I'm trying to use vagrant ssh in windows console, but it don't work.
Vagrant is correctly installed, and i've installed also Git for windows.
Also, correct path is installed in the system environment, using
setx PATH "%PATH%;C:\Program Files (x86)\Git\bin"
and i can see the path add-on in the console via path and also in the windows system environment.
But when i'm use vagrant ssh in the windows console it give me the usual error:
ssh executable not found in any directories in the %PATH% variable.
Is an SSH client installed? Try installing Cygwin, MinGW or Git, all
of which contain an SSH client. Or use your favorite SSH client with
the following authentication information shown below:
Host: 127.0.0.1 Port: 2222 Username: vagrant Private key:
C:/vagtest/.vagrant/machines/default/virtualbox/private_key
If i digit path in console, i have the correct path with git location, but it is useless.
If i digit
set PATH=%PATH%;C:\C:\Program Files (x86)\Git\bin
the command
vagrant ssh run, but obviusly when i close the console and reopen it, it don't run more.
I really don't understand what happen.
try >vagrant ssh from Git Bash window
To run ssh on windows, you need to download msysgit from msysgit project page and copy the ssh.exe file from msysgit/bin folder to C:\Program Files\Git\bin.
Now try again vagrant ssh from cmd, git cmd or git bash.
Note: if you prefer, you can include the msysgit/bin to path, or copy all the content of msysgit/bin to git/bin.

`Vagrant Up` not working in Pycharm

I have been trying to set up Vagrant with my project in PyCharm, but I've run into a problem. In Preferences > Vagrant I have set the path to the Vagrant executable (obtained via which vagrant), and I have set the instance folder to the project root. There is one Vagrant Box in the list on that same page (precise32 (virtualbox))
A Vagrantfile exists in my project, but when I go to Tools > Vagrant > Up, a file dialog appears, and regardless of what I select next (e.g. Vagrantfile, vagrant executable), nothing happens (i.e. the Run window doesn't open).
I've been looking at different pages in the Pycharm documentation but it has brought me no closer to an answer.
How can I get vagrant up working in Pycharm?
Note: I am using PyCharm 2.7 on Mac 10.7.5, if that helps
I had the same problem.
Go to Preferences --> Tools --> Vagrant and set your Vagrant executable to something like: /usr/local/bin/vagrant. In my case it looked like that somehow this settings was changed to vagrant. After I set the absolute path all worked fine again.

Resources