Skip to content

Instantly share code, notes, and snippets.

@cvrajeesh
Last active July 14, 2025 10:02
Show Gist options
  • Save cvrajeesh/2712478c2b7fff65707bb0a1023b2639 to your computer and use it in GitHub Desktop.
Save cvrajeesh/2712478c2b7fff65707bb0a1023b2639 to your computer and use it in GitHub Desktop.
prepare-workstation
#!/bin/bash
set -e
USER="user"
USER_HOME="/home/$USER"
# Update package list
echo "Updating package list"
apt update -y
# Install python3 if not present
if ! command -v python3 &> /dev/null; then
echo "Installing python3"
apt install -y python3
fi
# Install pip3
if ! command -v pip3 &> /dev/null; then
echo "Installing pip3"
apt install -y python3-pip
fi
# Install required packages
apt install python3-passlib -y
# Ensure .ssh directory exists
mkdir -p $USER_HOME/.ssh
chmod 700 $USER_HOME/.ssh
# SSH public key to add
SSH_PUB_KEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINSSCuPOi0l21a5BnFEyCLxTh4o+VKkt4S3G3VEzthPk Workstation admin"
# Add SSH key to authorized_keys if not present
if ! grep -Fq "$SSH_PUB_KEY" $USER_HOME/.ssh/authorized_keys 2>/dev/null; then
echo "$SSH_PUB_KEY" >> $USER_HOME/.ssh/authorized_keys
chmod 600 $USER_HOME/.ssh/authorized_keys
echo "SSH key added to authorized_keys"
fi
# Ensure SSH server is installed
if ! dpkg -l | grep -qw openssh-server; then
apt install -y openssh-server
fi
# Enable and start SSH server (Ubuntu uses 'ssh' service)
systemctl enable ssh
systemctl start ssh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment