Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/sh
##
## this is run on new cloudatcost.com system, to get me more set up
## disables root password login and adds my user.
##
bdimage="http://bazaar.launchpad.net/~smoser/+junk/backdoor-image/download/head:/backdoorimage-20121004180823-pi43gdnl3fbp82la-1/backdoor-image"
me_ssh_id="smoser"
gecos="Scott Moser"
user="smoser"
cfg="/etc/ssh/sshd_config"
if grep -q PermitRootLogin "$cfg"; then
if ! grep "^PermitRootLogin.*without-password" "$cfg"; then
sed -i 's,[#]*PermitRootLogin,PermitRootLogin without-password,' "$cfg"
fi
else
echo PermitRootLogin without-password >> "$cfg"
fi
pkgs="ssh-import-id git-core eatmydata"
apt-get update --quiet
apt-get install --assume-yes --quiet $pkgs
wget "$bdimage" -O "insert-user"
chmod 755 insert-user
./backdoor-image --import-id="$me_ssh_id" "--user=$user" --force /
sed -i "s,:backdoor:,:$gecos:," /etc/passwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment