Skip to content

Instantly share code, notes, and snippets.

@smoser
Created August 9, 2014 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smoser/e2e53b84431485c17e27 to your computer and use it in GitHub Desktop.
Save smoser/e2e53b84431485c17e27 to your computer and use it in GitHub Desktop.
#!/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