From 62f3b2c08d2163425a574b9292cfe7bc7daab859 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 28 Jan 2025 22:50:43 +0000 Subject: [PATCH] Initial commit 2 --- .env.example | 9 +++++++++ bootstrap.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ sshd_config | 11 +++++++++++ 3 files changed, 63 insertions(+) create mode 100644 .env.example create mode 100644 bootstrap.sh create mode 100644 sshd_config diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..1c7427a --- /dev/null +++ b/.env.example @@ -0,0 +1,9 @@ +# +# Global settings +# +APP_ENV= +USERNAME= +USER_PASSWORD= +DOMAIN= +LOCAL_IP= +SSH_KEY= # Will be added to authorized keys diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100644 index 0000000..e354b7c --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,43 @@ +# Force the locale +echo "LC_ALL=en_GB.UTF-8" >> /etc/default/locale +locale-gen en_US.UTF-8 + +# Set the hostname +echo "scarif.space" > /etc/hostname + +source /opt/mouse/.env + +echo "------- Generating system users -------" +useradd -m -p $(echo $USER_PASSWORD | openssl passwd -1 -stdin) chris +echo "chris ALL=(ALL) ALL" >> /etc/sudoers +passwd -l root + +echo "------- Installing packages -------" +apt-get -y update +apt-get -y tmux htop docker docker-compose zsh + +echo "------- Setting up SSH -------" +mkdir -p /home/chris/.ssh +echo $SSH_KEY >> /home/chris/.ssh/authorized_keys +rm /etc/ssh/sshd_config +ln -s /opt/mouse/sshd_config /etc/ssh/sshd_config +echo "Welcome to The Mouse!" > /etc/motd +systemctl restart sshd + +echo "------- Setting up firewall -------" +ufw default deny incoming +ufw default allow outgoing +ufw allow 629 +ufw --force enable + +echo "------- Install Cuda -------" +apt-key del 7fa2af80 +wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu24-4/x86_64/cuda-keyring_1.1-1_all.deb +sudo dpkg -i cuda-keyring_1.1-1_all.deb +sudo apt-get update +sudo apt-get install cuda-toolkit +sudo apt-get install nvidia-gds + +# echo "------- Starting docker -------" +# systemctl enable docker --now +# docker-compose -f "/opt/mouse/docker-compose.yml" --env-file "/opt/mouse/.env" up -d diff --git a/sshd_config b/sshd_config new file mode 100644 index 0000000..3e13ceb --- /dev/null +++ b/sshd_config @@ -0,0 +1,11 @@ +Port 629 +LoginGraceTime 1m +PermitRootLogin no +MaxSessions 4 +AllowUsers chris +PubkeyAuthentication yes +AuthorizedKeysFile .ssh/authorized_keys +ChallengeResponseAuthentication no +PrintMotd no +PasswordAuthentication yes +