At work, we use Vagrant on Windows 10 with the Hyper-V provider and, necessarily, SMB synced folders. It gets kind of annoying typing our entire corporate domain username and password every time we up
a box... is there any way to set default SMB credentials?
It needs to work with Vagrantfile
s checked into source control and cloned onto any developer machine.
Vagrant loads multiple Vagrantfiles from different locations. One of those being a user Vagrantfile.
~/.vagrant.d/Vagrantfile
https://www.vagrantup.com/docs/vagrantfile/#load-order-and-merging
But, the only username and _password like options, as of Vagrant 2.2.7, are provided directly on the synced_folder
method.
https://www.vagrantup.com/docs/synced-folders/smb.html#options
Something you can do in the meantime is pull defualt username and domain info from environment vars...
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
default_smb_username = ENV['USERNAME']
default_smb_username = "#{ENV['USERNAME']}@#{ENV['USERDNSDOMAIN'].downcase}" if ENV['USERDNSDOMAIN']
Vagrant.configure("2") do |config|
config.vm.synced_folder ".", "/vagrant"
config.vm.synced_folder ".", "/vagrant", smb_username: default_smb_username if default_smb_username
end
An issue has been opened asking for a solution.