aboutsummaryrefslogtreecommitdiff
path: root/system/vagrant-public-key/vagrant-basebox
diff options
context:
space:
mode:
authorBifferos <bifferos@gmail.com>2020-03-01 09:13:38 +0700
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2020-03-01 09:13:38 +0700
commit65ec57fe5820449810f623d93af9468b47300a34 (patch)
tree2124f91884b088a23b414d48e310fec680734de7 /system/vagrant-public-key/vagrant-basebox
parent2ae53c489998e61fcab07ed014c51cb8eaaaf96d (diff)
system/vagrant-public-key: Added (Vagrant Public Key).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'system/vagrant-public-key/vagrant-basebox')
-rw-r--r--system/vagrant-public-key/vagrant-basebox48
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"
+
+