Last active
April 15, 2026 03:36
-
-
Save ericchansen/8a7054a40f6c2701caf871d600bf0816 to your computer and use it in GitHub Desktop.
Fresh Ubuntu install script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Fresh Ubuntu / WSL2 setup script | |
| # | |
| # Installs essential build tools, configures Git credential forwarding | |
| # from Windows, sets up Docker, and wires up an SSH agent that persists | |
| # across shell sessions. | |
| # | |
| # Usage: | |
| # chmod +x install-with-fresh-ubuntu.sh && ./install-with-fresh-ubuntu.sh | |
| set -euo pipefail | |
| sudo apt-get update && sudo apt-get upgrade | |
| sudo apt-get -y install build-essential curl | |
| # Git credential manager — forward credentials from the Windows-side GCM. | |
| # Requires Git for Windows with Git Credential Manager installed on the host. | |
| git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager.exe" | |
| # Setup Docker. These directions work on WSL2. | |
| sudo addgroup --system docker | |
| sudo adduser $USER docker | |
| newgrp docker | |
| sudo chown root:docker /var/run/docker.sock | |
| sudo chmod g+w /var/run/docker.sock | |
| # Append SSH agent auto-start to ~/.bash_profile. | |
| # Reuses an existing agent if one is already running; starts a new one otherwise. | |
| cat >> ~/.bash_profile << 'EOF' | |
| # SSH agent — start once per login, reuse across shells | |
| if [ -z "${SSH_AUTH_SOCK:-}" ]; then | |
| if ! pgrep -u "$USER" ssh-agent > /dev/null; then | |
| ssh-agent -s > ~/.ssh/ssh-agent-env | |
| fi | |
| [ -f ~/.ssh/ssh-agent-env ] && eval "$(cat ~/.ssh/ssh-agent-env)" > /dev/null | |
| fi | |
| EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment