Skip to content

Instantly share code, notes, and snippets.

@jeffmccune
Created September 20, 2020 17:43
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 jeffmccune/dccae821ef1309d2976598cd99f5724a to your computer and use it in GitHub Desktop.
Save jeffmccune/dccae821ef1309d2976598cd99f5724a to your computer and use it in GitHub Desktop.
Setup Server
#! /bin/bash
#
# Initial setup of a server. Run this as root.
apt -qq -y install curl git sudo rsync
set -eu
install -o0 -g0 -m0700 -d /root/.ssh
tmpfile="$(mktemp)"
curl --location --silent --output "$tmpfile" https://github.com/jeffmccune.keys
install -o0 -g0 -m0644 "$tmpfile" /root/.ssh/authorized_keys
if [[ -d ~localadm ]]; then
install -olocaladm -glocaladm -m0700 -d ~localadm/.ssh
install -olocaladm -glocaladm -m0644 "$tmpfile" ~localadm/.ssh/authorized_keys
fi
rm -f "$tmpfile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment