Skip to content

Instantly share code, notes, and snippets.

@tbatchelli
Created July 15, 2012 22:45
Show Gist options
  • Save tbatchelli/3118982 to your computer and use it in GitHub Desktop.
Save tbatchelli/3118982 to your computer and use it in GitHub Desktop.
Cmd echo "package-manager update ..."
{ aptitude update || true; } || { echo "package-manager update " failed; exit 1; } >&2
echo "...done"
echo "Packages..."
{ { debconf-set-selections <<EOF
debconf debconf/frontend select noninteractive
debconf debconf/frontend seen false
EOF
} && aptitude install -q -y sudo+ && aptitude search "?and(?installed, ?name(^sudo$))" | grep "sudo"; } || { echo "Packages" failed; exit 1; } >&2
echo "...done"
if getent passwd tbatchelli; then /usr/sbin/usermod --shell "/bin/bash" tbatchelli;else /usr/sbin/useradd --shell "/bin/bash" --create-home tbatchelli;fi
file=/etc/sudoers
cat > ${file} <<EOF
root ALL = (ALL) ALL
%adm ALL = (ALL) ALL
tbatchelli ALL = (ALL) NOPASSWD: ALL
EOF
chmod 0440 ${file}
chown root ${file}
echo "Directory $(getent passwd tbatchelli | cut -d: -f6)/.ssh/..."
{ mkdir -m "755" -p $(getent passwd tbatchelli | cut -d: -f6)/.ssh/ && chown --recursive tbatchelli $(getent passwd tbatchelli | cut -d: -f6)/.ssh/ && chmod 755 $(getent passwd tbatchelli | cut -d: -f6)/.ssh/; } || { echo "Directory $(getent passwd tbatchelli | cut -d: -f6)/.ssh/" failed; exit 1; } >&2
echo "...done"
echo "file $(getent passwd tbatchelli | cut -d: -f6)/.ssh/authorized_keys..."
{ touch $(getent passwd tbatchelli | cut -d: -f6)/.ssh/authorized_keys && chown tbatchelli $(getent passwd tbatchelli | cut -d: -f6)/.ssh/authorized_keys && chmod 644 $(:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment