Skip to content

Instantly share code, notes, and snippets.

@heyimblake
Last active June 7, 2021 15:13
Initial Server Script from "Creating/Securing a Remote Dev Environment"
#!/bin/bash
# The name of the user to create (feel free to change)
# You will be logging into this user instead of root
USER_NAME="sammy"
# Create User, copy ssh key from root, remove password
adduser $USER_NAME
usermod -aG sudo $USER_NAME
rsync --archive --chown=$USER_NAME:$USER_NAME ~/.ssh /home/$USER_NAME
passwd -d -q $USER_NAME
# Only allow SSH (for now, you need to login before finishing the cloudflared setup)
ufw allow OpenSSH
ufw enable
# Update packages
apt-get -y update
# Install desired software
# Below are some commented-out (##) examples. Feel free to modify
# Java 11
## apt-get -y install openjdk-11-jdk-headless
# Git
## apt-get -y install git
# Install Docker
## curl -fsSL https://get.docker.com -o get-docker.sh
## sh get-docker.sh
## groupadd docker # Create a docker group
## usermod -aG docker $USER_NAME # Add user to the docker group
## newgrp docker # Ensure the group is loaded
# Don't modify this part.
# Install cloudflared (https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation)
mkdir /etc/cloudflared/
cd /etc/cloudflared/
wget -q https://bin.equinox.io/c/VdrWdbjqyF/cloudflared-stable-linux-amd64.deb
dpkg -i cloudflared-stable-linux-amd64.deb
chown -R $USER_NAME /etc/cloudflared/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment