Hashicorp Vagrant - How to authenticate against SMB if I have Microsoft Account on my windows host - vagrant

I have a windows 10 host and I would like to set up Synced Folders for my vagrant box. In my Vagrantfile I have:
Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/bionic64"
config.vm.synced_folder "./data", "/vagrant_data"
end
When I start up (or reload) my box, I get prompted for credentials:
PS D:\Vagrants\first> vagrant reload
==> default: Attempting graceful shutdown of VM...
default: Configuring the VM...
default: Setting VM Enhanced session transport type to disabled/default (VMBus)
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
default: Timeout: 120 seconds
default: IP: 172.27.23.149
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 172.27.23.149:22
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Preparing SMB shared folders...
default: You will be asked for the username and password to use for the SMB
default: folders shortly. Please use the proper username/password of your
default: account.
default:
default: Username (user[#domain]):
Either format I try to specify my microsoft credentials, it gets rejected. I tried both with and without windows PIN. Suppose my Microsoft account is username#outlook.com and password is mypass. Workgroup name on my windows machine is WORKGROUP.

I found a solution by:
disabling the Windows PIN and
as username using my "local" windows username (determined by windows environment variable %username% which also seems to equal to the folder named under C:\Users\USERNAME. Note that this is not the same as my Microsoft Account username) and
as password using my Microsoft Account password

Related

how to solve this SMB share folder when vagrant sync folder fail in this case?

I have a vagrant in my Win10 PC.
Vagrant.configure("2") do |config|
config.vm.box = "generic/centos7"
config.vm.synced_folder "D:/Users/88888888/vagrant_proj/vagrant_data", "/vagrant_data"
config.vm.network "private_network", ip: "172.22.244.28"
end
When I vagrant up my vm, I get below error when sync folder:
MINGW64 ~/vagrant_proj/vagrant_vm/vmware_desktop_centos7
$ vagrant up
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Verifying Hyper-V is accessible...
default: Configuring the VM...
default: Setting VM Enhanced session transport type to disabled/default (VMBus)
Vagrant requires administrator access for pruning SMB shares and
may request access to complete removal of stale shares.
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
default: Timeout: 120 seconds
default: IP: 172.22.244.28
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 172.22.244.28:22
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Preparing SMB shared folders...
default: You will be asked for the username and password to use for the SMB
default: folders shortly. Please use the proper username/password of your
default: account.
default:
default: Username (user[#domain]): ABC\88888888
default: Password (will be hidden):
Error! Your console doesn't support hiding input. We'll ask for
input again below, but we WILL NOT be able to hide input. If this
is a problem for you, ctrl-C to exit and fix your stdin.
default: Password (will be hidden): Aircraft04!
Vagrant requires administrator access to create SMB shares and
may request access to complete setup of configured shares.
==> default: Mounting SMB shared folders...
default: D:/Users/88888888/vagrant_proj/vagrant_data => /vagrant_data
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t cifs -o vers=2.0,credentials=/etc/smb_creds_vgt-2d3036366c24d0c86eee3d4f63f20f4f-adda498f781708cde2d8e46c475e9593,uid=1000,gid=1000,mfsymlinks,_netdev,nofail //10.0.129.112/vgt-2d3036366c24d0c86eee3d4f63f20f4f-adda498f781708cde2d8e46c475e9593 /vagrant_data
The error output from the last command was:
mount error(5): Input/output error
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
how to solve this SMB share folder?
the version is below:
$ vagrant.exe --version
Vagrant 2.2.19
and I use the vagrant HyperV provider.

Vagrant - Failed to mount folders in Linux Guest using Puphpet and SMB mounting

I'm trying to set up Vagrant on Windows 10.
I have Vagrant 2.0.1, Virtual Box 5.2.4 and Guest Additions 5.2.4.
I had issues whilst Virtual Box and Guest Additions were not the same versions, but now I've bought them inline with each other I still get an error.
I am running Git Bash as Administrator too. Here is the output from git bash.
The vagrantfile is generated through Puphpet and I didn't really change much within puphpet setup. I added SMB for the shared folders as it recommended this. I did not supply a username or password, and when prompted for both during vagrant up I just leave them both blank.
I've seen and read the other articles on SO and not had any luck with them.
$ vagrant up Bringing machine 'machine1' up with 'virtualbox' provider...
==> machine1: Importing base box 'bento/ubuntu-16.04'...
==> machine1: Matching MAC address for NAT networking...
==> machine1: Checking if box 'bento/ubuntu-16.04' is up to date...
==> machine1: Setting the name of the VM: Ubuntu_machine1_1517300867334_22288
==> machine1: Preparing SMB shared folders...
machine1: You will be asked for the username and password to use for the SMB
machine1: folders shortly. Please use the proper username/password of your
machine1: Windows account.
machine1:
machine1: Username:
machine1: Password (will be hidden): Error! Your console doesn't support hiding input. We'll ask for input again below, but we WILL NOT be able to hide input. If this is a problem for you, ctrl-C to exit and fix your stdin.
machine1: Password (will be hidden):
==> machine1: Clearing any previously set network interfaces...
==> machine1: Preparing network interfaces based on configuration...
machine1: Adapter 1: nat
machine1: Adapter 2: hostonly
==> machine1: Forwarding ports...
machine1: 22 (guest) => 5741 (host) (adapter 1)
machine1: 22 (guest) => 2222 (host) (adapter 1)
==> machine1: Running 'pre-boot' VM customizations...
==> machine1: Booting VM...
==> machine1: Waiting for machine to boot. This may take a few minutes...
machine1: SSH address: 127.0.0.1:2222
machine1: SSH username: vagrant
machine1: SSH auth method: private key
==> machine1: Machine booted and ready! [machine1] GuestAdditions 5.2.4 running --- OK.
==> machine1: Checking for guest additions in VM...
==> machine1: Setting hostname...
==> machine1: Configuring and enabling network interfaces...
==> machine1: Mounting SMB shared folders...
machine1: E:/Simon/Sites => /var/www Failed to mount folders in Linux guest. This is usually because the "vboxsf" file system is not available. Please verify that the guest additions are properly installed in the guest and can work properly. The command attempted was:
PASSWORDHIDDENmPASSWORDHIDDENoPASSWORDHIDDENuPASSWORDHIDDENnPASSWORDHIDDENtPASSWORDHIDDEN PASSWORDHIDDEN-PASSWORDHIDDENtPASSWORDHIDDEN PASSWORDHIDDENcPASSWORDHIDDENiPASSWORDHIDDENfPASSWORDHIDDENsPASSWORDHIDDEN PASSWORDHIDDEN-PASSWORDHIDDENoPASSWORDHIDDEN PASSWORDHIDDENuPASSWORDHIDDENiPASSWORDHIDDENdPASSWORDHIDDEN=PASSWORDHIDDEN3PASSWORDHIDDEN3PASSWORDHIDDEN,PASSWORDHIDDENgPASSWORDHIDDENiPASSWORDHIDDENdPASSWORDHIDDEN=PASSWORDHIDDEN3PASSWORDHIDDEN3PASSWORDHIDDEN,PASSWORDHIDDENmPASSWORDHIDDENfPASSWORDHIDDENsPASSWORDHIDDENyPASSWORDHIDDENmPASSWORDHIDDENlPASSWORDHIDDENiPASSWORDHIDDENnPASSWORDHIDDENkPASSWORDHIDDENsPASSWORDHIDDEN,PASSWORDHIDDENdPASSWORDHIDDENiPASSWORDHIDDENrPASSWORDHIDDEN_PASSWORDHIDDENmPASSWORDHIDDENoPASSWORDHIDDENdPASSWORDHIDDENePASSWORDHIDDEN=PASSWORDHIDDEN0PASSWORDHIDDEN7PASSWORDHIDDEN7PASSWORDHIDDEN5PASSWORDHIDDEN,PASSWORDHIDDENfPASSWORDHIDDENiPASSWORDHIDDENlPASSWORDHIDDENePASSWORDHIDDEN_PASSWORDHIDDENmPASSWORDHIDDENoPASSWORDHIDDENdPASSWORDHIDDENePASSWORDHIDDEN=PASSWORDHIDDEN0PASSWORDHIDDEN6PASSWORDHIDDEN6PASSWORDHIDDEN4PASSWORDHIDDEN,PASSWORDHIDDENvPASSWORDHIDDENePASSWORDHIDDENrPASSWORDHIDDENsPASSWORDHIDDEN=PASSWORDHIDDEN3PASSWORDHIDDEN.PASSWORDHIDDEN0PASSWORDHIDDEN,PASSWORDHIDDENsPASSWORDHIDDENePASSWORDHIDDENcPASSWORDHIDDEN=PASSWORDHIDDENnPASSWORDHIDDENtPASSWORDHIDDENlPASSWORDHIDDENmPASSWORDHIDDEN,PASSWORDHIDDENcPASSWORDHIDDENrPASSWORDHIDDENePASSWORDHIDDENdPASSWORDHIDDENePASSWORDHIDDENnPASSWORDHIDDENtPASSWORDHIDDENiPASSWORDHIDDENaPASSWORDHIDDENlPASSWORDHIDDENsPASSWORDHIDDEN=PASSWORDHIDDEN/PASSWORDHIDDENePASSWORDHIDDENtPASSWORDHIDDENcPASSWORDHIDDEN/PASSWORDHIDDENsPASSWORDHIDDENmPASSWORDHIDDENbPASSWORDHIDDEN_PASSWORDHIDDENcPASSWORDHIDDENrPASSWORDHIDDENePASSWORDHIDDENdPASSWORDHIDDENsPASSWORDHIDDEN_PASSWORDHIDDENbPASSWORDHIDDEN6PASSWORDHIDDEN5PASSWORDHIDDEN0PASSWORDHIDDENcPASSWORDHIDDEN4PASSWORDHIDDEN2PASSWORDHIDDEN2PASSWORDHIDDENePASSWORDHIDDEN5PASSWORDHIDDEN5PASSWORDHIDDENbPASSWORDHIDDEN2PASSWORDHIDDENcPASSWORDHIDDENfPASSWORDHIDDEN1PASSWORDHIDDEN4PASSWORDHIDDENfPASSWORDHIDDENaPASSWORDHIDDEN0PASSWORDHIDDEN5PASSWORDHIDDENcPASSWORDHIDDEN1PASSWORDHIDDEN8PASSWORDHIDDEN6PASSWORDHIDDENfPASSWORDHIDDEN0PASSWORDHIDDEN3PASSWORDHIDDEN4PASSWORDHIDDEN7PASSWORDHIDDEN3PASSWORDHIDDENcPASSWORDHIDDEN PASSWORDHIDDEN/PASSWORDHIDDEN/PASSWORDHIDDEN1PASSWORDHIDDEN9PASSWORDHIDDEN2PASSWORDHIDDEN.PASSWORDHIDDEN1PASSWORDHIDDEN6PASSWORDHIDDEN8PASSWORDHIDDEN.PASSWORDHIDDEN1PASSWORDHIDDEN.PASSWORDHIDDEN7PASSWORDHIDDEN0PASSWORDHIDDEN/PASSWORDHIDDENbPASSWORDHIDDEN6PASSWORDHIDDEN5PASSWORDHIDDEN0PASSWORDHIDDENcPASSWORDHIDDEN4PASSWORDHIDDEN2PASSWORDHIDDEN2PASSWORDHIDDENePASSWORDHIDDEN5PASSWORDHIDDEN5PASSWORDHIDDENbPASSWORDHIDDEN2PASSWORDHIDDENcPASSWORDHIDDENfPASSWORDHIDDEN1PASSWORDHIDDEN4PASSWORDHIDDENfPASSWORDHIDDENaPASSWORDHIDDEN0PASSWORDHIDDEN5PASSWORDHIDDENcPASSWORDHIDDEN1PASSWORDHIDDEN8PASSWORDHIDDEN6PASSWORDHIDDENfPASSWORDHIDDEN0PASSWORDHIDDEN3PASSWORDHIDDEN4PASSWORDHIDDEN7PASSWORDHIDDEN3PASSWORDHIDDENcPASSWORDHIDDEN PASSWORDHIDDEN/PASSWORDHIDDENvPASSWORDHIDDENaPASSWORDHIDDENrPASSWORDHIDDEN/PASSWORDHIDDENwPASSWORDHIDDENwPASSWORDHIDDENwPASSWORDHIDDEN
The error output from the last command was:
mount error(13): Permission denied Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Thanks!
So after reading closer, the username/password it asks for is your windows username and password. Now, that doesn't help in windows 10 if you have run through the setup process and created a Windows account online. If you have the same problems as me, make sure to check your account settings under account management, and "switch to local account" to create a local account for yourself. You'll be prompted to supply a password (needed, as PIN didn't work either). Log in to this user, and try again supplying your new credentials.
I hope this helps someone.

Vagrant + Hyper V IPV6 addresses Assigned

I have been having a lot of troubles with Vagrant 2.0.1 on Windows 10 with Hyper V.
When I do vagrant up I receive an ipv6 address. Which chef can't access and fails to provision the virtual:
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Configured startup memory is 2048
==> default: Configured cpus number is 2
==> default: Importing a Hyper-V instance
default: Cloning virtual hard drive...
default: Creating and registering the VM...
default: Setting VM Integration Services
default: Successfully imported a VM with name: vargrant-dev-source
==> default: Installing Chef cookbooks with Librarian-Chef...
==> default: Auto-generating node name for Chef...
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
default: Timeout: 120 seconds
default: IP: fe80::215:5dff:fe02:f5a
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: fe80::215:5dff:fe02:f5a:22
default: SSH username: vagrant
default: SSH auth method: private key
... Eventually times out here ....
I used the following commands to set up a NATed switch:
New-VMSwitch –SwitchName “NATSwitch” –SwitchType Internal
New-NetIPAddress –IPAddress 172.21.21.1 -PrefixLength 24 -InterfaceAlias "vEthernet (NATSwitch)"
New-NetNat –Name MyNATnetwork –InternalIPInterfaceAddressPrefix 172.21.21.0/24
Interestingly everything works the first time I set up the VM switch and I get a valid IPV4 address and things are okay. But after I reboot the virtual machines will only ever get IPV6 addresses and I cant access existing ones created before the reboot.
My vagrant file:
Vagrant.configure("2") do |config|
config.vm.provider "hyperv"
config.vm.box = "maxx/ubuntu16"
config.vm.boot_timeout = 2000
config.vm.network "private_network", ip: "172.21.21.2"
... general config omitted.
end
I have tried both DHCP and static and both seem to fail. With static IP seemingly ignored completely.
Any ideas what I'm missing or doing wrong? (I am using a wifi connection if that is relevant)
I found a way around it by using internet connection sharing between my wifi and the virtual hyper v network. But currently, there is a bug in windows build 1607 where internet connection sharing needs to be restarted after every reboot.
A large thread here on the MS forums:
https://answers.microsoft.com/en-us/windows/forum/windows_10-networking/ics-internet-connection-sharing-dosent-work-in/a203c90f-1214-4e5e-ae90-9832ae5ceb55

vagrant asks password at only the first time 'vagrant up'

I made my custom vagrant box for CentOS 6.6.
My question is why vagrant always requires password when I 'vagrant up' at only first time.
Here is the console log:
$ vagrant up
Bringing machine 'ns' up with 'virtualbox' provider...
==> ns: Clearing any previously set forwarded ports...
==> ns: Clearing any previously set network interfaces...
==> ns: Preparing network interfaces based on configuration...
ns: Adapter 1: nat
ns: Adapter 2: hostonly
==> ns: Forwarding ports...
ns: 22 => 2222 (adapter 1)
==> ns: Running 'pre-boot' VM customizations...
==> ns: Booting VM...
==> ns: Waiting for machine to boot. This may take a few minutes...
ns: SSH address: 127.0.0.1:2222
ns: SSH username: vagrant
ns: SSH auth method: private key
ns: Warning: Connection timeout. Retrying...
ns: Warning: Connection timeout. Retrying...
ns: Warning: Remote connection disconnect. Retrying...
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
vagrant#127.0.0.1's password:
As you see, vagrant asks password. It continues after I type it. After that, vagrant never ask it whenever I do 'vagrant up'. This occurs at only the first time 'vagrant up'.
I wonder something of my custom box's setting, maybe ssh, is wrong but don't understand where the problem is.
Can anybody guess the possible causes?
Environment:
the version of vagrant is 1.7.2. Host OS is ubuntu 15.04 and Guest OS is CentOS 6.6.
You may also want to try the default vagrant password: vagrant.
Vagrant asks for the password when it can't login automatically. The most obvious reason is that Vagrant does not have the required user key for the user vagrant. Then your entering the correct password and vagrant exchanges the key. Afterwards this does not appear anymore. This key exchange is manager per instance, so if you destroy/delete the instance then next time your ask again to login manually.
Vagrant offers an insecure key on Github and any distributed public available Vagrant box is packaged with it. You can put this key by executing this inside the machine:
wget https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys
The other way is to use your own private key and configure the Vagrantfile to use the specific key:
Vagrant SSH Config
Vagrant itself will recognize and exchange the insecure key immediately and exchange it for a secure one. Therefore, you have to set this key with Hashicorp Packer.
I entered the password "vagrant" when this happened to me and got right in. See this Vagrant Github issue. Also see this stackoverflow question.

Vagrant tries to force WinRM with windows guest when I specify ssh should be used

I have a windows guest with cygwin and openssh installed, with user/password configured in the Vagrantfile. When I run vagrant up, everything works until "configuring and enabling network interfaces", at which point it barfs and complains about winrm being required for windows vagrant boxes:
==> default: Waiting for domain to get an IP address...
==> default: Waiting for SSH to become available...
==> default: Starting domain.
==> default: Waiting for domain to get an IP address...
==> default: Waiting for SSH to become available...
==> default: Creating shared folders metadata...
==> default: Configuring and enabling network interfaces...
Configuring networks on Windows requires the communicator to be
set to WinRM. To do this, add the following to your Vagrantfile:
config.vm.communicator = "winrm"
Note that the Windows guest must be configured to accept insecure
WinRM connections, and the WinRM port must be forwarded properly from
the guest machine. This is not always done by default.
How can I get it to stop doing this?

Resources