Tuesday, November 26, 2013

How to make Ubuntu Desktop Vagrant compliant

Its seems me reasonable to have Vagrant compliant Ubuntu Desktop 12.04 even I will not start it from commandline. These steps are necessary:
  1. Create default user as vagrant/vagrant in Ubuntu setup
  2. Add admin group
    groupadd admin
    useradd -a -G admin vagrant
  3. update sudoers (sudo visudo; and add these lines
    Defaults:vagrant !requiretty
    Defaults env_keep = "SSH_AUTH_SOCK"
    %admin   ALL=(ALL:ALL) NOPASSWD: ALL
  4. Add a port forwarding rule in Virtualbox NAT as follows:
        Name: SSH
        Protocol: TCP
        Host IP:
        Host Port: 2222
        Guest IP:
        Guest Port: 22
  5. Install and configure OpenSSH Server
    sudo apt-get install -y openssh-server
    sudo vi /etc/ssh/sshd_config

    and add/modify these lines:
    Port 22
    PubKeyAuthentication yes
    AuthorizedKeysFile %h/.ssh/authorized_keys
    PermitEmptyPasswords no
    PasswordAuthentication no

    restart ssh server
  6. Download vargant public and private key
    $ mkdir -p /home/vagrant/.ssh
    $ chmod 0700 /home/vagrant/.ssh
    $ wget --no-check-certificate \
        https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub \
        -O /home/vagrant/.ssh/authorized_keys
    $ chmod 0600 /home/vagrant/.ssh/authorized_keys
    $ wget --no-check-certificate \
        https://raw.github.com/mitchellh/vagrant/master/keys/vagrant \
        -O /home/vagrant/.ssh/id_rsa
    $ chmod 0600 /home/vagrant/.ssh/id_rsa
    $ chown -R vagrant /home/vagrant/.ssh
  7. Remove file to fix network issues afterward
    sudo rm -f /etc/udev/rules.d/70-persistent-net.rule
  8. Comment out HWADDR row in /etc/sysconfig/network-scripts/ifcfg-eth1 (to fix https://github.com/mitchellh/vagrant/issues/1777 issue)
After that you are ready to create new vagrant box. There are several articles describing same process in depth.

No comments:

Post a Comment