Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL SSH key error when not running in user directory or WSL filesystem #8742

Closed
robwiss opened this issue Jun 30, 2017 · 6 comments · Fixed by #8824
Closed

WSL SSH key error when not running in user directory or WSL filesystem #8742

robwiss opened this issue Jun 30, 2017 · 6 comments · Fixed by #8824

Comments

@robwiss
Copy link

robwiss commented Jun 30, 2017

Vagrant version

Vagrant 1.9.6

Host operating system

Microsoft Windows 10 Pro Version 10.0.15063 Build 15063, running vagrant from the WSL

Guest operating system

centos/7 base box

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
end

Debug output

https://gist.github.com/robwiss/9642b52c8f108082c34de94645f26448

Expected behavior

Vagrant should remove the insecure private key and insert the new private key.

Actual behavior

Vagrant fails to insert the new private key if the directory containing the Vagrantfile is not located in the WSL filesystem or the Windows user's home directory.

Error is as follows:

The private key to connect to the machine via SSH must be owned
by the user running Vagrant. This is a strict requirement from
SSH itself. Please fix the following key to be owned by the user
running Vagrant:

/mnt/c/temp/.vagrant/machines/default/virtualbox/private_key

See the debug output for full error info.

Steps to reproduce

  1. Make a directory under /mnt/c from within the WSL (or make it in Windows)
  2. Add a Vagrantfile
  3. Run vagrant up
@nick4fake
Copy link

Temporary solution could be to create a wrapper that issues the following:

#!/bin/bash
sudo -e PATH="${PATH}" vagrant $@

(as WSL translates user to root) but there is still file permission problem (should be 0600).

A workaround is to create symlink:

mv .vagrant ~/.project-vagrant
ln -sv ~/.project-vagrant .vagrant

@chrisroberts
Copy link
Member

Vagrant will ignore file permission checks when the path is within the path set in the VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH. This is set as the user's home directory on the Windows system by default but can be overridden to a custom location. @robwiss, for you this would look like:

export VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH="/mnt/c/temp"

The relevant env var documentation is located here: https://www.vagrantup.com/docs/other/wsl.html#vagrant_wsl_windows_access_user_home_path The details of the impact each of those env vars still needs to be added, and this ticket will be closed once they have been included.

@robwiss
Copy link
Author

robwiss commented Jul 13, 2017

@chrisroberts thank you

@dthunder746
Copy link

@chrisroberts thanks for that, solved my problem. Do you know if I can add this env var to a config file or something, so I don't need to run it every morning after I log in?

@antonwestman
Copy link

@dthunder746 You could put it in ~/.bash-profile, ~/.profile or, preferrably not, in ~/.bashrc

@ghost
Copy link

ghost commented Mar 31, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants