Skip to content

Instantly share code, notes, and snippets.

@oliveiraev
Last active December 25, 2015 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oliveiraev/7027013 to your computer and use it in GitHub Desktop.
Save oliveiraev/7027013 to your computer and use it in GitHub Desktop.
Set up any debian/redhat-based distro ready for vagrant.
test "$(command -v su)" || (echo "su is required but not found" && exit 1)
RUN="su"
test "$(command -v sudo)" && RUN="sudo su"
$RUN -c'
INSTALLER="apt-get"
test "$(command -v yum)" && INSTALLER="yum"
$INSTALLER install -y openssh-server
printf "\n#Vagrant additions\n" >> /etc/sudoers
useradd -s$SHELL vagrant
sed -ri "s/^vagrant:[^:]/vagrant:\!/" /etc/shadow
echo "vagrant ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
echo "Defaults:vagrant !requiretty" >> /etc/sudoers
SSHDIR=$(grep vagrant /etc/passwd | awk -F":" "{print \$(NF-1)}")/.ssh
mkdir -p -m700 $SSHDIR
wget -qO$SSHDIR/authorized_keys --no-check-certificate https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub
chown -R vagrant: $SSHDIR/..'
@oliveiraev
Copy link
Author

Usage: curl -sL https://gist.github.com/oliveiraev/7027013/raw/linux-to-vagrant.sh | bash
Wget option: wget -qO - https://gist.github.com/oliveiraev/7027013/raw/linux-to-vagrant.sh | bash

You can use any smart shell: curl -sL https://gist.github.com/oliveiraev/7027013/raw/linux-to-vagrant.sh | zsh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment