#!/bin/bash
# Add the user
sudo useradd -m clarkeb -s '/bin/bash'
sudo echo -e 'password\npassword\n' | sudo passwd clarkeb
# Set up sudo
echo "clarkeb ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/10_clarkeb
# Allow password based login
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
sed -i 's/ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/g' /etc/ssh/sshd_config
service sshd restart
An example Vagrantfile snippet to invoke the above script
config.vm.define "core01" do |core01|
core01.vm.provision "shell", path: "create-user.sh"
core01.vm.hostname = "core01"
core01.vm.network "private_network", ip: "10.1.1.101"
core01.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
vb.customize ["modifyvm", :id, "--cpus", "1"]
end
end
No comments:
Post a Comment