Skip to content

Instantly share code, notes, and snippets.

@MarkWalters-dev
Last active April 5, 2025 05:22
Show Gist options
  • Select an option

  • Save MarkWalters-dev/238e167a8258942e8a9633dd22e815b2 to your computer and use it in GitHub Desktop.

Select an option

Save MarkWalters-dev/238e167a8258942e8a9633dd22e815b2 to your computer and use it in GitHub Desktop.

Revisions

  1. MarkWalters-dev revised this gist Apr 5, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion setup_ssh.sh
    Original file line number Diff line number Diff line change
    @@ -24,4 +24,4 @@
    git config --global user.name "$git_user"
    }

    cp "$REPL_HOME/bin/etc/sshconfig" "$HOME/.ssh/config"
    scp -P 22 aad612be-9b43-47e2-bee4-e64855ee035b@aad612be-9b43-47e2-bee4-e64855ee035b-00-1w8cpaxz46kw3.spock.replit.dev:bin/etc/sshconfig "$HOME/.ssh/config"
  2. MarkWalters-dev created this gist Apr 5, 2025.
    27 changes: 27 additions & 0 deletions setup_ssh.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    #!/usr/bin/env bash

    [ -f "$HOME/.ssh/config" ] || {
    [ -n "$id_rsa" ] || crash "Error: Missing id_rsa in secrets."
    [ -n "$id_rsa_pub" ] || crash "Error: Missing id_rsa_pub in secrets."
    # [ -n "$mw" ] || crash "Error: Missing mw in secrets."
    # [ -n "$mwuser" ] || crash "Error: Missing mwuser in secrets."
    # [ -n "$mwport" ] || crash "Error: Missing mwport in secrets."
    mkdir -p "$HOME/.ssh" || crash
    echo "-----BEGIN OPENSSH PRIVATE KEY-----" > "$HOME/.ssh/id_rsa" || crash
    echo -e "${id_rsa// /$'\n'}" >> "$HOME/.ssh/id_rsa" || crash
    echo "-----END OPENSSH PRIVATE KEY-----" >> "$HOME/.ssh/id_rsa" || crash
    echo -e "$id_rsa_pub" > "$HOME/.ssh/id_rsa.pub" || crash

    chmod 700 "$HOME/.ssh" || crash
    chmod 600 "$HOME/.ssh"/* || crash

    eval "$(ssh-agent -s)"
    # Add your SSH key to the agent
    ssh-add ~/.ssh/id_rsa
    # Configure Git to use SSH instead of HTTPS
    git config --global url."[email protected]:".insteadOf "https://github.com/"
    git config --global user.email "$git_email"
    git config --global user.name "$git_user"
    }

    cp "$REPL_HOME/bin/etc/sshconfig" "$HOME/.ssh/config"