- create a user vagrant with password vagrant
- install VMware Tools
- enable and configure ssh
- configure sudo
1. create a user vagrant with password vagrant
To meet the first requirement we can simply go through Setup Assistant in the guest OS X instance specifying the account name vagrant and the password vagrant.
2. install VMware tools
Once we have a usable machine the next thing we should do is install the VMware Tools. This allows the vagrant project folder to be mounted in the guest at /vagrant. To do this VMware will mount a disc inside the virtual machine that contains the VMware tools installer.
- In the host OS select the Virtual Machine menu in VMware Fusion
- Select Install VMware Tools
- Fusion will present a warning sheet informing you that it will mount a fake disc in order to complete the installation. Simply click Install
- In the guest OS double click on the Install VMware Tools package and restart the VM when prompted.
3. To enable and configure ssh we need to do the following:
- enable ssh aka Remote Login in System Preferences' Sharing pane
- Vagrant boxes typically allow login via publicly available keys. This can be changed, if required, for security reasons but that is beyond the scope of this document. Also, when `vagrant up` detects that the public key is in use it automatically creates a new key and injects it into the machine increasing the security somewhat. To enable login via key we need to create a hidden folder and obtain the public key from github.
- open Terminal and type (or copy & paste) the following commands
- mkdir ~/.ssh
- cd ~/.ssh
- curl https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub -o authorized_keys
- chmod 600 authorized_keys
- cd ..
- chmod 700 .ssh
- The Vagrant docs suggest that we disable DNS lookups to increase ssh performance for VMs that may not have a connection to the internet.
- still within Terminal open ssh_config in your editor of choice
- sudo vim /etc/ssh_config
- add the following line to the very end of the document and save it
- UseDNS no
ProTip: in vim you can do this quickly by typing: G, o, UseDNS no, <esc>, <shift> + <Z><Z>
4. configure sudo
The last thing we need to configure in the VM is sudo. Vagrant uses sudo to perform tasks in the guest OS that require elevated privileges. The docs also suggest setting the root password to vagrant but this is not required, especially in OS X where root availability is not an expectation. Configuring sudo properly is very important to prevent errors later.
In the following steps I will present exactly what needs to be typed in vim for you to do what is required. If you don't know vi/m don't worry. Using visudo to edit /etc/sudoers in this VM is not technically required but it is a good habit to get in to.
- open Terminal if it is not still open from previous steps and type the following. < > contain the names of keyboard keys to press, otherwise simply type the letters as they appear to send the correct commands to vim
- sudo visudo<enter>
- cw vagrant
|The file should look like this before you :wq|
CleanupAs a final bit of cleanup before shutting down:
- type the command "history -c" in Terminal and then quit it
- clear Recent Folders in the Go menu of Finder
- clear Recent Items in the Apple Menu
In the next post we will pack up the VM into a box and finally start playing with vagrant.