Skip to content

Instantly share code, notes, and snippets.

@pvalena
Created May 27, 2020 21:52
Show Gist options
  • Save pvalena/2a4feb4a1c383a4a872a4d32241b2d52 to your computer and use it in GitHub Desktop.
Save pvalena/2a4feb4a1c383a4a872a4d32241b2d52 to your computer and use it in GitHub Desktop.
➜ cat > Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
# Copy inserted SSH keys for root
config.vm.provision :shell, inline: "cp -vfr /home/vagrant/.ssh/ /root/"
# If running 'vagrant ssh' command, use 'root' user
if ARGV.first == 'ssh'
config.ssh.username = "root"
end
end
➜ vagrant up ; vagrant ssh -c 'echo "USER = $USER (`id`)"'
Bringing machine 'default' up with 'libvirt' provider...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> default: Creating image (snapshot of base box volume).
==> default: Creating domain with the following settings...
==> default: -- Name: 3_default
==> default: -- Domain type: kvm
==> default: -- Cpus: 1
==> default: -- Feature: acpi
==> default: -- Feature: apic
==> default: -- Feature: pae
==> default: -- Memory: 512M
==> default: -- Management MAC:
==> default: -- Loader:
==> default: -- Nvram:
==> default: -- Base box: centos/7
==> default: -- Storage pool: default
==> default: -- Image: /home/lpcs/.local/share/libvirt/images/3_default.img (41G)
==> default: -- Volume Cache: default
==> default: -- Kernel:
==> default: -- Initrd:
==> default: -- Graphics Type: vnc
==> default: -- Graphics Port: -1
==> default: -- Graphics IP: 127.0.0.1
==> default: -- Graphics Password: Not defined
==> default: -- Video Type: cirrus
==> default: -- Video VRAM: 9216
==> default: -- Sound Type:
==> default: -- Keymap: en-us
==> default: -- TPM Path:
==> default: -- INPUT: type=mouse, bus=ps2
==> default: Creating shared folders metadata...
==> default: Starting domain.
==> default: Waiting for domain to get an IP address...
==> default: Waiting for SSH to become available...
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Rsyncing folder: /home/lpcs/lpcsf-new/tmp/3/ => /vagrant
==> default: Running provisioner: shell...
default: Running: inline script
default: ‘/home/vagrant/.ssh/’ -> ‘/root/.ssh’
default: ‘/home/vagrant/.ssh/authorized_keys’ -> ‘/root/.ssh/authorized_keys’
USER = root (uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment