Skip to content

Instantly share code, notes, and snippets.

@pwnedDesal
Created August 5, 2016 01:31
Show Gist options
  • Save pwnedDesal/09347373da94befa37b2e255805ef5cd to your computer and use it in GitHub Desktop.
Save pwnedDesal/09347373da94befa37b2e255805ef5cd to your computer and use it in GitHub Desktop.
ssh in windows
The **S**ecure **Sh**ell ("SSH") protocol is all about security and Vagrant is prepackaged with an SSH key. Unfortunately, PuTTY is not compatible with OpenSSH, out-of-the-box. Consequently, PuTTY will **not** recognize the `insecure_private_key` (which is in OpenSSH format) provided by Vagrant as a valid, private key.
>The file is named `insecure_private_key` only because it is not very *private*, in that it is publicly available, because it ships with Vagrant. You can regain the security offered by the SSH protocol by creating your own SSH key pair and editing the [Vagrantfile](http://docs.vagrantup.com/v2/vagrantfile/ssh_settings.html), accordingly.
A workaround is to use [PuTTYgen](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) (a free, open-source RSA and DSA key generation utility) to import and convert the `insecure_private_key` into PuTTY's format (a `.ppk` file). To do so, simply:
1. Open the PuTTYgen utility;
1. Click on the `Load` button;
1. Navigate to the `...\.vagrant.d\` folder in your local machine's Home Directory; e.g.
* Windows XP: `C:\Documents and Settings\{your username}\.vagrant.d\`
* Windows 7: `C:\Users\{your username}\.vagrant.d\`
1. Double-click on the `insecure_private_key` file;
1. Toward the bottom of the PuTTYgen dialog box, change the value in the `Number of bits in a generated key:` field to `2048`;
1. Click on the `Save private key` button.
Run "vagrant ssh-config" and make note of the HostName, User and Port being used.
Then, launch PuTTY and enter the following connection information:
Category | Sub-category | Field | Value
--- | --- | --- | ---
Session | | **Host Name:** | 127.0.0.1
| | | **Port:** | 2222
| | | **Connection type:** | SSH
| Connection | Data | **Auto-login username:** | vagrant
| Connection/SSH | Auth | **Private key file for authentication:** | Click on the `Browse` button and find the `.ppk` private key you just converted
| Session | | **Saved Sessions** | vagrant (and then click the `Save` button for the `Load, save or delete a stored session` area)
Finally, click on the `Open` button, at the bottom of the PuTTY window, to log in to your Vagrant VM.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment