diff options
Diffstat (limited to 'system/vagrant-public-key/vagrant-basebox')
-rw-r--r-- | system/vagrant-public-key/vagrant-basebox | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/system/vagrant-public-key/vagrant-basebox b/system/vagrant-public-key/vagrant-basebox new file mode 100644 index 0000000000000..4211766c38de9 --- /dev/null +++ b/system/vagrant-public-key/vagrant-basebox @@ -0,0 +1,48 @@ +#!/bin/sh -e + +# vagrant base box preparation script. + + +# Some safeguards +if grep -q "^avagrant:" /etc/passwd ; then + echo "vagrant user has already been created." + exit +fi + +if test -f /root/.ssh/authorized_keys; then + echo "root already has /root/.ssh/authorized_keys, refusing to overwrite it." + exit +fi + + +# Create vagrant user and give them the key. +echo "Creating user vagrant" +useradd -m vagrant +mkdir -p /home/vagrant/.ssh +echo "Adding Vagrant authorized key for user vagrant" +cp /etc/vagrant/vagrant.pub /home/vagrant/.ssh/authorized_keys +chown -R vagrant:users /home/vagrant +chmod 0700 /home/vagrant/.ssh +chmod 0600 /home/vagrant/.ssh/authorized_keys + + +# Add the key to root as well. +echo "Adding vagrant authorized key for user root" +mkdir -p /root/.ssh +cp /etc/vagrant/vagrant.pub /root/.ssh/authorized_keys +chmod 0700 /root/.ssh +chmod 0600 /root/.ssh/authorized_keys + + +echo "Adding vagrant to /etc/sudoers" +echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers +echo "Adding 'UseDNS no' to /etc/ssh/sshd_config" +echo "UseDNS no" >> /etc/ssh/sshd_config +echo "PermitRootLogin yes" >> /etc/ssh/sshd_config + + +echo +echo "THIS SYSTEM IS NOW INSECURE, AND ACCESSIBLE TO ANYONE WITH THE VAGRANT PRIVATE KEY" +echo "FROM https://github.com/hashicorp/vagrant/blob/master/keys/vagrant" + + |