mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-24 10:02:29 +01:00
65ec57fe58
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
48 lines
1.3 KiB
Bash
48 lines
1.3 KiB
Bash
#!/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"
|
|
|
|
|