Created
September 12, 2026 03:51
-
-
Save greenlikeorange/df3cc80600ff1255b2e0b8e4eef6897f to your computer and use it in GitHub Desktop.
Install sre-box SSH pubkey (Grok Computer) for ubuntu — rescue or live
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/sh | |
| # Install Grok Computer sre-box pubkey for ubuntu (run as root in rescue, with disk mounted at /mnt) | |
| # Or run on a live system as root/ubuntu to add the key for ubuntu. | |
| set -eu | |
| PUB='ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIArwfOKNfq5NfnNuCwaig59IT/km1X58eGuaqBV3XZ/L sre@grok-computer ovhsgp-01' | |
| MARKER='sre@grok-computer ovhsgp-01' | |
| if [ -d /mnt/home/ubuntu ]; then | |
| HOME_UBUNTU=/mnt/home/ubuntu | |
| elif [ -d /home/ubuntu ]; then | |
| HOME_UBUNTU=/home/ubuntu | |
| else | |
| echo "No /mnt/home/ubuntu or /home/ubuntu found" >&2 | |
| exit 1 | |
| fi | |
| mkdir -p "$HOME_UBUNTU/.ssh" | |
| chmod 700 "$HOME_UBUNTU/.ssh" | |
| AUTH="$HOME_UBUNTU/.ssh/authorized_keys" | |
| touch "$AUTH" | |
| chmod 600 "$AUTH" | |
| if grep -qF "$MARKER" "$AUTH" 2>/dev/null; then | |
| echo "Key already present in $AUTH" | |
| else | |
| echo "$PUB" >> "$AUTH" | |
| echo "Key added to $AUTH" | |
| fi | |
| # fix ownership when possible | |
| if grep -q '^ubuntu:' /mnt/etc/passwd 2>/dev/null; then | |
| U=$(awk -F: '/^ubuntu:/{print $3}' /mnt/etc/passwd) | |
| G=$(awk -F: '/^ubuntu:/{print $4}' /mnt/etc/passwd) | |
| chown -R "$U:$G" "$HOME_UBUNTU/.ssh" || true | |
| elif id ubuntu >/dev/null 2>&1; then | |
| chown -R ubuntu:ubuntu "$HOME_UBUNTU/.ssh" || true | |
| fi | |
| grep -F "$MARKER" "$AUTH" >/dev/null && echo OK |
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
| ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIArwfOKNfq5NfnNuCwaig59IT/km1X58eGuaqBV3XZ/L sre@grok-computer ovhsgp-01 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment