This tutorial is going to cover shortly about running vagrant ssh on windows by different approaches. Probably, this will be useful when you want to use vagrant ssh command to ssh directly to your Vagrant box on Windows.

1. Problem and root cause

On Windows, SSH to a Vagrant box by running vagrant ssh command often throws an error as the following:

The root cause could be because Vagrant could not found any SSH client in the Windows system path.

2. Solutions for running vagrant ssh on Windows

From the error log, Vagrant does recommend us 2 approaches for running vagrant ssh on Windows

  • Install Cygwin, MinGW or Git (They both includes SSH client)
  • Use our favorite SSH client

Hence, in this article, we are going to get through both 2 approaches.

2.1. Install Git

Step 1. Download and install proper Git client for Windows from its website.

If you already installed Git, move to the step 2.

Step 2. Add the following paths in to the Windows system path.

  • C:\Program Files\Git\cmd
  • C:\Program Files\Git\mingw64\bin
  • C:\Program Files\Git\usr\bin

To do that, you can do as below instructions:

  • In Windows 7, right click on My Computer and select Properties > Advanced.
    In Windows 8, Windows 10,  go to Control Panel > System > Advanced System Settings > Environment Variables
  • Select the Path variable and append the above Git paths to the Path variable.

Here is an example on my Windows 10 machine.

Add Git paths to system Path variable

Add Git paths to system Path variable

Step 3. Verify again by executing the vagrant ssh command from the box directory. Here is my output of running vagrant ssh on windows

2.2. Using Putty as a SSH client

Another way is to use a SSH client to ssh to the Vagrant box from Windows. And as you may know that Putty is a very popular SSH client for Windows. You can download a version on the Putty website.

After downloading, start Putty and review the recommendation of Vagrant again.

First of all, it’s easy to see that we already had enough information to ssh to Vagrant box by using the provided private key. However, if we also know the password of the vagrant user, we will be able to ssh to the box using the password. As a result, we come up with 2 approaches to ssh to the Vagrant box with Putty as the following:

2.2.1. SSH to Vagrant box using password

This is the easiest way. If you know the password of the vagrant user, you just need to start Putty do following steps:

  • Input the Host:, Port: 2222, Saved Session: Centos7
  • Click Save button
  • Click Open button
vagrant ssh using putty

ssh using putty

Input the following information.

  • login as: vagrant
  • vagrant@’s password: [The vagrant’s password]
vagrant ssh putty login

putty login

Then you should be logged in successfully.

2.2.2. SSH to Vagrant box using private key Generate private key followed Putty format

The private key is located at the VM location. Here is an example on my machine.

For this approach, you will have to download the PuTTYgen from the Putty website.

  • Start PuTTYgen
  • Menu File –> Load Private key
  • Browse to the Vagrant box private key (D:/Working/vagrant/centos7-3/.vagrant/machines/default/virtualbox/private_key)
  • There will be a popup appeared to notify that the key was imported successfully
    Vagrant SSH on Windows -Import private key successfully

    Import private key successfully

  • Click OK to close the popup
  • Click “Save private key” button to save the private key to Desktop with your desire name, for example: centos7pk
  • Exit the PuTTYgen SSH to Vagrant box using Putty and new private key

Let’s review Vagrant recommendation again

  • Start Putty and input information as below:


vagrant ssh using putty

ssh using putty

  • Select the Data tab and in the input “vagrant” for the field Auto-login username
input vagrant for Auto-login username

input vagrant for Auto-login username

  • Expand the Connection node –> expand SSH –> select the Auth node.
  • Browse to the key we have just generated above by PuTTYgen.
Locate the private key

Locate the private key

  • And click the Open button will get us logged in to the VM.

3. Summary

We have just learned how to run vagrant ssh on Windows. Because there is no SSH client on Windows by default, Vagrant cannot find and invoke the ssh command accordingly. Thefore, to fix that, we have to install a favorite one by ourselves. We also got through 2 approaches including to install Git with extra configuration of the Path and to use the Putty. If anyone is using Git, this approach should be very easy while the Putty approach takes more effort.

4. References

Install Vagrant on Ubuntu 16.04 LTS (Xenial Xerus)

Basic Vagrant Commands

How to Add a Vagrant Box from Local or Remote

Set Name, Number of CPUs, Memory and GUI Mode for Vagrant Virtual Machines

0 0 vote
Article Rating