diff --git a/rin/miner/.vscode/settings.json b/rin/miner/.vscode/settings.json index 9b29c69..1e38824 100644 --- a/rin/miner/.vscode/settings.json +++ b/rin/miner/.vscode/settings.json @@ -10,7 +10,7 @@ "configure": "shellscript" }, "terminal.integrated.shell.linux": "/bin/bash", - "terminal.integrated.shellArgs.linux": [], + "terminal.integrated.shellArgs.linux": ["-l"], "cmake.configureOnOpen": false, "C_Cpp.default.compilerPath": "/usr/bin/gcc", "C_Cpp.default.cStandard": "c11", @@ -23,7 +23,7 @@ "C_Cpp.default.defines": [ "HAVE_CONFIG_H" ], - "docker.host": "tcp://localhost:2375", + "docker.host": "unix:///var/run/docker.sock", "docker.certificates": [], "docker.tlsVerify": false, "docker.machineName": "", @@ -60,5 +60,16 @@ "task.saveBeforeRun": "prompt", "remote.SSH.configFile": "~/.ssh/config", "remote.SSH.showLoginTerminal": true, - "remote.SSH.useLocalServer": true + "remote.SSH.useLocalServer": true, + "git.enableSmartCommit": true, + "git.autofetch": true, + "git.confirmSync": false, + "git.enableCommitSigning": false, + "git.useEditorAsCommitInput": false, + "git.untrackedChanges": "separate", + "git.openDiffOnClick": true, + "git.defaultCloneDirectory": "~/Projects", + "git.ignoreLegacyWarning": true, + "git.showInlineOpenFileAction": true, + "git.showPushSuccessNotification": true } diff --git a/rin/miner/BUILD_GUIDE.md b/rin/miner/BUILD_GUIDE.md index af1a7ed..5a17de5 100644 --- a/rin/miner/BUILD_GUIDE.md +++ b/rin/miner/BUILD_GUIDE.md @@ -8,6 +8,41 @@ sudo apt update sudo apt install build-essential autotools-dev autoconf pkg-config libcurl4-openssl-dev libjansson-dev libssl-dev libgmp-dev zlib1g-dev git automake libtool docker.io ``` +#### Git Credential Setup (Linux Users) +If VS Code keeps asking for Git credentials, set up credential management: + +**Quick Setup (Linux Mint - Recommended):** +```bash +cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner +./setup-git-credentials-linux.sh +``` + +**Test Your Setup:** +```bash +./test-git-credentials-linux.sh +``` + +**Available Methods:** +- ✅ **SSH Keys** - Most secure, no password prompts (recommended) +- ✅ **GNOME Keyring** - Encrypted storage using system keyring +- ✅ **Git Credential Cache** - Temporary credential caching +- ✅ **Personal Access Tokens** - For custom Git servers +- ✅ **VS Code Integration** - Built-in credential storage + +**For git.d-popov.com (your custom server):** +1. **SSH Keys (Recommended):** + - Run setup script and choose SSH option + - Copy public key to git.d-popov.com + - Test: `ssh -T git@git.d-popov.com` + +2. **Personal Access Token:** + - Generate token in git.d-popov.com web interface + - Use username + token as password + +3. **GNOME Keyring:** + - Automatic encrypted storage + - Integrated with system credentials + ### 🛠️ VS Code Integration (Recommended) If you're using VS Code, the project now includes pre-configured tasks for easy building: @@ -140,50 +175,59 @@ Create `.devcontainer/devcontainer.json`: } ``` -### Option 6: Docker Desktop Remote Connection (Windows 11) -**For Windows 11 users with Docker Desktop:** +### Option 6: Remote Docker Access (Linux Mint) +**For Linux Mint users accessing remote Docker:** -#### Windows Setup: -1. **Install Docker Desktop for Windows:** - - Download from: https://www.docker.com/products/docker-desktop - - Enable WSL 2 integration during installation +#### Local Linux Setup: +1. **Install Docker locally (optional):** + ```bash + sudo apt update + sudo apt install -y docker.io + sudo systemctl enable docker + sudo usermod -aG docker $USER + # Logout and login again, or run: newgrp docker + ``` -2. **Enable Docker Remote API:** - - Open Docker Desktop → Settings → General - - Enable "Expose daemon on tcp://localhost:2375 without TLS" +2. **SSH Setup:** + - SSH is built-in on Linux Mint + - Generate SSH key if needed: `ssh-keygen -t ed25519` -3. **Install OpenSSH Client:** - - Windows 11 has OpenSSH built-in - - Enable in: Settings → Apps → Optional features → OpenSSH Client +#### SSH Port Forwarding: +```bash +# Forward Docker socket from remote machine +ssh -L localhost:2375:/var/run/docker.sock user@remote-build-machine -#### Windows SSH Port Forwarding: -```cmd -REM Command Prompt: -ssh -L localhost:2375:/var/run/docker.sock user@build-machine-ip +# Set environment variable +export DOCKER_HOST=tcp://localhost:2375 -REM PowerShell: -ssh -L localhost:2375:/var/run/docker.sock user@build-machine-ip +# Test remote connection +docker run --rm cpuminer-windows-builder echo "Remote Docker working!" ``` -#### Windows Environment Setup: -```cmd -REM Command Prompt: -set DOCKER_HOST=tcp://localhost:2375 +#### Docker Contexts: +```bash +# Create context for remote machine +docker context create build-server --docker "host=ssh://user@remote-build-machine" -REM PowerShell: -$env:DOCKER_HOST = "tcp://localhost:2375" -``` - -#### Windows Docker Contexts: -```cmd -REM Create context for remote Linux machine: -docker context create build-server --docker "host=ssh://user@build-machine-ip" - -REM Switch to remote context: +# Switch to remote context docker context use build-server -REM Test remote connection: -docker run --rm cpuminer-windows-builder echo "Windows remote Docker working!" +# All docker commands now work remotely +docker ps +docker run --rm cpuminer-windows-builder echo "Remote Docker working!" +``` + +#### VS Code Remote Development: +```bash +# Install VS Code extensions: +code --install-extension ms-vscode-remote.remote-ssh +code --install-extension ms-vscode.vscode-docker + +# Connect to remote machine: +# Ctrl+Shift+P → "Remote-SSH: Connect to Host" +# Enter: ssh user@remote-build-machine + +# Use Docker extension on remote machine ``` ### 🔒 Security Recommendations @@ -197,33 +241,30 @@ docker run --rm cpuminer-windows-builder echo "Windows remote Docker working!" **Quick Start (Most Secure):** -**For Windows 11:** -```powershell -# On build machine - automated setup: -cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner -./setup-remote-docker.sh - -# On your Windows 11 machine - run setup script: -.\setup-remote-docker-windows.bat - -# Or use PowerShell script: -.\setup-remote-docker-windows.ps1 -``` - -**For Linux/Mac:** +**For Linux Mint (Local Development):** ```bash -# On build machine - automated setup: +# On your Linux Mint machine - automated setup: cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner ./setup-remote-docker.sh -# On your local machine: -ssh -L localhost:2375:/var/run/docker.sock user@build-machine +# For remote Docker access: +ssh -L localhost:2375:/var/run/docker.sock user@remote-build-machine export DOCKER_HOST=tcp://localhost:2375 docker run --rm cpuminer-windows-builder echo "Ready for remote builds!" ``` +**For Remote Docker Access:** +```bash +# Create Docker context for remote machine: +docker context create build-server --docker "host=ssh://user@remote-build-machine" +docker context use build-server + +# All Docker commands now work remotely: +docker run --rm cpuminer-windows-builder echo "Remote Docker working!" +``` + 📖 **Detailed Instructions:** -- **Windows 11:** See [REMOTE_DOCKER_README.md](REMOTE_DOCKER_README.md) for comprehensive setup guide +- **Linux Mint:** See [REMOTE_DOCKER_README.md](REMOTE_DOCKER_README.md) for comprehensive setup guide - **All Platforms:** Check [BUILD_GUIDE.md](BUILD_GUIDE.md) for additional remote access options ### 1. Build GPU Library (ROCm/HIP) diff --git a/rin/miner/GIT_CREDENTIALS_QUICKSTART.md b/rin/miner/GIT_CREDENTIALS_QUICKSTART.md new file mode 100644 index 0000000..c3de107 --- /dev/null +++ b/rin/miner/GIT_CREDENTIALS_QUICKSTART.md @@ -0,0 +1,171 @@ +# Git Credentials Quick Start Guide + +## 🚀 Quick Setup (Choose One Method) + +### Method 1: Git Credential Manager (Recommended for Windows) +```powershell +# Run the setup script +cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner +.\setup-git-credentials.ps1 + +# Choose option 1 (Git Credential Manager) +``` + +**What it does:** +- Installs Microsoft's Git Credential Manager +- Configures Git to use it +- Opens browser for authentication +- Securely stores credentials + +### Method 2: SSH Keys (Most Secure) +```powershell +# Run the setup script +cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner +.\setup-git-credentials.ps1 + +# Choose option 3 (SSH Keys) +``` + +**What it does:** +- Generates SSH key pair +- Shows public key to add to git.d-popov.com +- Changes remote URL to SSH +- Enables passwordless authentication + +### Method 3: Personal Access Token +```powershell +# Run the setup script +cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner +.\setup-git-credentials.ps1 + +# Choose option 4 (Personal Access Token) +``` + +**What it does:** +- Configures Git to store credentials +- Next push/pull will prompt for token +- Remembers credentials for future use + +## 🧪 Test Your Setup + +```powershell +# Test script +cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner +.\test-git-credentials.ps1 +``` + +This will: +- ✅ Check your credential configuration +- ✅ Test Git operations +- ✅ Provide troubleshooting tips +- ✅ Show SSH key status (if using SSH) + +## 🔧 Manual Commands (If Needed) + +### Clear Stored Credentials +```bash +# Clear all stored credentials +git config --global --unset credential.helper +git config --global credential.helper store # Reset to basic store + +# Or clear specific credentials +git config --global --unset-all credential.helper +``` + +### Change Remote URL +```bash +# Check current remote +git remote -v + +# Change to SSH (if you have SSH keys) +git remote set-url origin git@git.d-popov.com:popov/mines.git + +# Change back to HTTPS +git remote set-url origin https://git.d-popov.com/popov/mines.git +``` + +### SSH Key Setup (Manual) +```bash +# Generate SSH key +ssh-keygen -t ed25519 -C "your-email@example.com" + +# Start SSH agent +eval "$(ssh-agent -s)" +ssh-add ~/.ssh/id_ed25519 + +# Copy public key to clipboard (Windows) +type %USERPROFILE%\.ssh\id_ed25519.pub | clip + +# Test SSH connection +ssh -T git@git.d-popov.com +``` + +## 🚨 Troubleshooting + +### VS Code Still Asks for Credentials +1. **Check credential helper:** + ```bash + git config --global credential.helper + ``` + +2. **Clear VS Code's Git cache:** + - VS Code: `Ctrl+Shift+P` → "Git: Clear Credentials" + +3. **Reset Git configuration:** + ```bash + git config --global --unset credential.helper + # Then run setup script again + ``` + +### SSH Connection Issues +```bash +# Test SSH connection +ssh -T git@git.d-popov.com + +# Debug SSH +ssh -v git@git.d-popov.com + +# Check SSH agent +ssh-add -l +``` + +### Permission Denied +- ✅ Check if SSH key is added to git.d-popov.com +- ✅ Verify SSH key has correct permissions (600) +- ✅ Make sure you're using the correct username + +### Authentication Failed +- ✅ Verify Personal Access Token hasn't expired +- ✅ Check if token has correct permissions +- ✅ Try regenerating the token + +## 📋 For git.d-popov.com Server + +### Generate Personal Access Token: +1. Log into git.d-popov.com web interface +2. Go to User Settings → Access Tokens +3. Create new token with `read/write` permissions +4. Copy token (you won't see it again!) + +### Add SSH Key: +1. Log into git.d-popov.com web interface +2. Go to User Settings → SSH Keys +3. Paste your public key (`id_ed25519.pub`) +4. Save and test: `ssh -T git@git.d-popov.com` + +## 🔐 Security Best Practices + +- ✅ **SSH Keys**: Most secure, no passwords stored +- ✅ **Git Credential Manager**: Secure storage with encryption +- ⚠️ **Store Credentials**: Plain text (avoid on shared computers) +- ✅ **Personal Access Tokens**: Time-limited, can be revoked +- ✅ **Regular Rotation**: Change tokens/keys periodically + +## 📞 Need Help? + +1. Run the test script: `.\test-git-credentials.ps1` +2. Check VS Code Git output panel for errors +3. Verify your Git server configuration +4. Try different authentication methods + +**Quick Fix:** Run `.\setup-git-credentials.ps1` and choose option 1 (GCM) - it usually solves most issues! 🎯 diff --git a/rin/miner/GIT_CREDENTIALS_QUICKSTART_LINUX.md b/rin/miner/GIT_CREDENTIALS_QUICKSTART_LINUX.md new file mode 100644 index 0000000..fc80106 --- /dev/null +++ b/rin/miner/GIT_CREDENTIALS_QUICKSTART_LINUX.md @@ -0,0 +1,216 @@ +# Git Credentials Quick Start Guide (Linux Mint) + +## 🚀 Quick Setup (Choose One Method) + +### Method 1: SSH Keys (Most Secure - Recommended) +```bash +# Run the setup script +cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner +./setup-git-credentials-linux.sh + +# Choose option 1 (SSH Keys) +``` + +**What it does:** +- Generates SSH key pair automatically +- Shows public key to add to git.d-popov.com +- Changes remote URL to SSH for passwordless access +- Tests SSH connection + +### Method 2: GNOME Keyring (Encrypted Storage) +```bash +# Run the setup script +cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner +./setup-git-credentials-linux.sh + +# Choose option 4 (GNOME Keyring) +``` + +**What it does:** +- Installs git-credential-libsecret +- Configures Git to use GNOME Keyring +- Stores credentials encrypted in system keyring +- Works with Seahorse (Passwords and Keys) + +### Method 3: Personal Access Token +```bash +# Run the setup script +cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner +./setup-git-credentials-linux.sh + +# Choose option 5 (Personal Access Token) +``` + +**What it does:** +- Configures Git to store credentials +- Next push/pull will prompt for token +- Remembers credentials for future use + +## 🧪 Test Your Setup + +```bash +# Test script +cd /mnt/shared/DEV/repos/d-popov.com/mines/rin/miner +./test-git-credentials-linux.sh +``` + +This will: +- ✅ Check your credential configuration +- ✅ Test Git operations +- ✅ Verify SSH keys (if using SSH) +- ✅ Provide troubleshooting tips + +## 🔧 Manual Commands (If Needed) + +### SSH Key Setup (Manual) +```bash +# Generate SSH key +ssh-keygen -t ed25519 -C "your-email@example.com" + +# Start SSH agent (if not running) +eval "$(ssh-agent -s)" +ssh-add ~/.ssh/id_ed25519 + +# Copy public key to clipboard +xclip -sel clip < ~/.ssh/id_ed25519.pub + +# Test SSH connection +ssh -T git@git.d-popov.com +``` + +### Change Remote URL +```bash +# Check current remote +git remote -v + +# Change to SSH (recommended) +git remote set-url origin git@git.d-popov.com:popov/mines.git + +# Change back to HTTPS +git remote set-url origin https://git.d-popov.com/popov/mines.git +``` + +### GNOME Keyring Setup (Manual) +```bash +# Install dependencies +sudo apt update +sudo apt install -y libsecret-1-0 libsecret-1-dev + +# Build and install git-credential-libsecret +cd /tmp +git clone https://github.com/git-ecosystem/git-credential-libsecret.git +cd git-credential-libsecret +sudo make install + +# Configure Git +git config --global credential.helper libsecret +``` + +## 🚨 Troubleshooting + +### VS Code Still Asks for Credentials +1. **Check credential helper:** + ```bash + git config --global credential.helper + ``` + +2. **Clear VS Code's Git cache:** + - VS Code: `Ctrl+Shift+P` → "Git: Clear Credentials" + +3. **Reset Git configuration:** + ```bash + git config --global --unset credential.helper + # Then run setup script again + ``` + +### SSH Connection Issues +```bash +# Test SSH connection +ssh -T git@git.d-popov.com + +# Debug SSH +ssh -v git@git.d-popov.com + +# Check SSH agent +ssh-add -l +``` + +### Permission Denied +- ✅ Check if SSH key is added to git.d-popov.com +- ✅ Verify SSH key has correct permissions (600) +- ✅ Make sure you're using the correct username + +### Authentication Failed +- ✅ Verify Personal Access Token hasn't expired +- ✅ Check if token has correct permissions +- ✅ Try regenerating the token + +## 📋 For git.d-popov.com Server + +### Generate Personal Access Token: +1. Log into git.d-popov.com web interface +2. Go to User Settings → Access Tokens +3. Create new token with `read/write` permissions +4. Copy token (you won't see it again!) + +### Add SSH Key: +1. Log into git.d-popov.com web interface +2. Go to User Settings → SSH Keys +3. Paste your public key (`~/.ssh/id_ed25519.pub`) +4. Save and test: `ssh -T git@git.d-popov.com` + +## 🔐 Security Best Practices + +- ✅ **SSH Keys**: Most secure, no passwords stored +- ✅ **GNOME Keyring**: Encrypted storage, system integration +- ⚠️ **Store Credentials**: Plain text (avoid on shared computers) +- ✅ **Personal Access Tokens**: Time-limited, can be revoked +- ✅ **Regular Rotation**: Change tokens/keys periodically + +## Linux Mint Specific Features + +### Seahorse (Passwords and Keys) +```bash +# Install Seahorse +sudo apt install -y seahorse + +# Launch from menu or command: +seahorse + +# View/manage Git credentials stored in GNOME Keyring +``` + +### SSH Agent Integration +```bash +# Check if SSH agent is running +ps aux | grep ssh-agent + +# Start SSH agent automatically (add to ~/.bashrc) +if [ -z "$SSH_AGENT_PID" ]; then + eval "$(ssh-agent -s)" +fi + +# Add SSH key to agent +ssh-add ~/.ssh/id_ed25519 +``` + +### Git Configuration for Linux +```bash +# View all Git config +git config --list --show-origin + +# Set up credential cache (15 minutes) +git config --global credential.helper cache + +# Custom cache timeout (1 hour) +git config --global credential.helper 'cache --timeout=3600' +``` + +## 📞 Need Help? + +1. Run the test script: `./test-git-credentials-linux.sh` +2. Check VS Code Git output panel for errors +3. Verify your Git server configuration +4. Try different authentication methods + +**Quick Fix:** Run `./setup-git-credentials-linux.sh` and choose option 1 (SSH Keys) - it usually solves most issues! 🎯 diff --git a/rin/miner/setup-git-credentials-linux.sh b/rin/miner/setup-git-credentials-linux.sh new file mode 100644 index 0000000..5300155 --- /dev/null +++ b/rin/miner/setup-git-credentials-linux.sh @@ -0,0 +1,288 @@ +#!/bin/bash +# +# Git Credential Setup for Linux Mint +# Interactive setup script for managing Git credentials + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +PURPLE='\033[0;35m' +CYAN='\033[0;36m' +NC='\033[0m' # No Color + +# Function to print colored output +print_header() { + echo -e "${CYAN}================================${NC}" + echo -e "${CYAN}$1${NC}" + echo -e "${CYAN}================================${NC}" + echo "" +} + +print_step() { + echo -e "${BLUE}➤ $1${NC}" +} + +print_success() { + echo -e "${GREEN}✅ $1${NC}" +} + +print_warning() { + echo -e "${YELLOW}⚠️ $1${NC}" +} + +print_error() { + echo -e "${RED}❌ $1${NC}" +} + +print_info() { + echo -e "${PURPLE}ℹ️ $1${NC}" +} + +# Main script +print_header "🔐 Git Credential Setup for Linux Mint" + +# Check if Git is installed +if ! command -v git &> /dev/null; then + print_error "Git is not installed" + echo "" + echo "Installing Git..." + sudo apt update && sudo apt install -y git + print_success "Git installed successfully" +fi + +print_success "Git found: $(git --version)" + +# Check current Git config +echo "" +print_info "Current Git Configuration:" +echo "User Name: $(git config --global user.name 2>/dev/null || echo 'Not set')" +echo "User Email: $(git config --global user.email 2>/dev/null || echo 'Not set')" +echo "Credential Helper: $(git config --global credential.helper 2>/dev/null || echo 'Not set')" +echo "" + +# Check if we're in a Git repository +if [ -d ".git" ]; then + print_info "Current Repository:" + echo "Remote URL: $(git remote get-url origin 2>/dev/null || echo 'No remote')" + echo "" +fi + +# Menu options +echo "" +print_info "Available Git Credential Methods:" +echo "1. SSH Keys (Most Secure - Recommended)" +echo "2. Git Credential Cache (Temporary)" +echo "3. Git Credential Store (Persistent)" +echo "4. GNOME Keyring (If available)" +echo "5. Personal Access Token" +echo "6. VS Code Integration" +echo "" + +read -p "Choose your preferred method (1-6): " choice + +case $choice in + 1) + print_step "Setting up SSH Keys..." + echo "" + + # Check if SSH key already exists + ssh_key_path="$HOME/.ssh/id_ed25519" + if [ -f "$ssh_key_path" ]; then + print_success "SSH key already exists at: $ssh_key_path" + else + print_info "Generating new SSH key..." + ssh-keygen -t ed25519 -C "$(git config --global user.email)" -f "$ssh_key_path" -N "" + + print_success "SSH key generated successfully" + fi + + # Display public key + echo "" + print_info "SSH Public Key (add this to your Git server):" + echo "----------------------------------------" + cat "${ssh_key_path}.pub" + echo "----------------------------------------" + echo "" + + print_step "Next steps:" + echo "1. Copy the public key above" + echo "2. Add it to your Git server (git.d-popov.com)" + echo "3. Test SSH connection: ssh -T git@git.d-popov.com" + echo "" + + # Ask if user wants to change remote URL to SSH + read -p "Change remote URL to SSH? (y/n): " change_remote + if [[ $change_remote =~ ^[Yy]$ ]]; then + current_url=$(git remote get-url origin) + if [[ $current_url == https://* ]]; then + ssh_url=$(echo $current_url | sed 's|https://git\.d-popov\.com/|git@git.d-popov.com:|g') + git remote set-url origin "$ssh_url" + print_success "Remote URL changed to SSH: $ssh_url" + else + print_warning "Remote URL is already using SSH or non-HTTPS protocol" + fi + fi + ;; + + 2) + print_step "Setting up Git Credential Cache..." + echo "" + + # Set up credential cache + git config --global credential.helper cache + + print_success "Git credential cache configured" + echo "" + print_info "This will cache credentials for 15 minutes by default" + echo "To change timeout: git config --global credential.helper 'cache --timeout=3600'" + ;; + + 3) + print_step "Setting up Git Credential Store..." + echo "" + + print_warning "This stores credentials in plain text!" + read -p "Continue anyway? (y/n): " confirm + if [[ ! $confirm =~ ^[Yy]$ ]]; then + print_info "Setup cancelled" + exit 0 + fi + + git config --global credential.helper store + print_success "Git credential store configured" + echo "" + print_warning "Credentials will be stored in plain text at: ~/.git-credentials" + ;; + + 4) + print_step "Setting up GNOME Keyring..." + echo "" + + # Check if GNOME Keyring is available + if command -v gnome-keyring-daemon &> /dev/null; then + # Install GNOME Keyring credential helper + sudo apt update && sudo apt install -y libsecret-1-0 libsecret-1-dev + + # Build and install git-credential-libsecret if not available + if ! command -v git-credential-libsecret &> /dev/null; then + print_info "Building git-credential-libsecret..." + + # Create temporary directory + temp_dir=$(mktemp -d) + cd "$temp_dir" + + # Download and build + git clone https://github.com/git-ecosystem/git-credential-libsecret.git + cd git-credential-libsecret + sudo make install + + # Clean up + cd / + rm -rf "$temp_dir" + fi + + git config --global credential.helper libsecret + print_success "GNOME Keyring configured as credential helper" + else + print_error "GNOME Keyring is not available on this system" + print_info "Falling back to credential cache..." + git config --global credential.helper cache + fi + ;; + + 5) + print_step "Setting up Personal Access Token..." + echo "" + + print_info "For git.d-popov.com, you'll need to:" + echo "1. Go to your Git server web interface" + echo "2. Generate a Personal Access Token" + echo "3. Use your username + token as password" + echo "" + + git config --global credential.helper store + print_success "Git configured to store credentials" + echo "" + print_info "Next time you push/pull:" + echo "- Username: Your Git username" + echo "- Password: [your personal access token]" + echo "- Git will remember these credentials" + ;; + + 6) + print_step "Setting up VS Code Integration..." + echo "" + + # Configure VS Code as credential helper + git config --global credential.helper vscode + print_success "VS Code configured as credential helper" + echo "" + print_info "Next time you use Git in VS Code:" + echo "- VS Code will prompt for credentials" + echo "- Choose 'Save' to store them securely" + echo "- Credentials are stored per-repository" + ;; + + *) + print_error "Invalid choice. Please run the script again." + exit 1 + ;; +esac + +echo "" +print_success "Git credential setup complete!" +echo "" +print_info "Test your setup:" +echo " git fetch" +echo " git pull" +echo " git push" +echo "" +print_info "For troubleshooting, run:" +echo " ./test-git-credentials-linux.sh" +echo "" + +# Create test script +cat > test-git-credentials-linux.sh << 'EOF' +#!/bin/bash +# Git Credentials Test Script for Linux + +echo "🧪 Git Credentials Test" +echo "======================" +echo "" + +# Check Git config +echo "📋 Git Configuration:" +echo "User Name: $(git config --global user.name)" +echo "User Email: $(git config --global user.email)" +echo "Credential Helper: $(git config --global credential.helper)" +echo "" + +# Test Git operations +echo "🔍 Testing Git Operations:" +echo -n "git fetch: " +if git fetch --quiet 2>/dev/null; then + echo "✅ Success" +else + echo "❌ Failed" +fi + +echo -n "git status: " +if git status --porcelain >/dev/null 2>&1; then + echo "✅ Success" +else + echo "❌ Failed" +fi + +echo "" +echo "📝 Troubleshooting:" +echo "• Clear credentials: git config --global --unset credential.helper" +echo "• Test SSH: ssh -T git@git.d-popov.com" +echo "• Check Git config: git config --list --show-origin" +EOF + +chmod +x test-git-credentials-linux.sh +print_success "Created test script: test-git-credentials-linux.sh" diff --git a/rin/miner/setup-git-credentials.bat b/rin/miner/setup-git-credentials.bat new file mode 100644 index 0000000..b8885d9 --- /dev/null +++ b/rin/miner/setup-git-credentials.bat @@ -0,0 +1,205 @@ +@echo off +REM Git Credential Setup for Windows +REM Batch file version for Command Prompt users + +echo. +echo ================================= +echo 🔐 Git Credential Setup for Windows +echo ================================= +echo. + +REM Check if Git is installed +git --version >nul 2>&1 +if %errorlevel% neq 0 ( + echo ❌ Error: Git is not installed + echo. + echo Please install Git for Windows: + echo Download: https://gitforwindows.org/ + echo Or via winget: winget install --id Git.Git -e --source winget + echo. + pause + exit /b 1 +) + +echo ✅ Git found: +git --version +echo. + +REM Show current Git config +echo 📋 Current Git Configuration: +echo User Name: +git config --global user.name +echo User Email: +git config --global user.email +echo Credential Helper: +git config --global credential.helper +echo. + +REM Check if we're in a Git repository +if exist .git ( + echo 📁 Current Repository: + echo Remote URL: + git remote get-url origin + echo. +) + +echo 🔧 Git Credential Setup Options: +echo 1. Git Credential Manager (Recommended) +echo 2. Personal Access Token +echo 3. SSH Keys (Most Secure) +echo 4. VS Code Integration +echo 5. Store Credentials (Less Secure) +echo. + +set /p choice="Choose your preferred method (1-5): " + +if "%choice%"=="1" goto :gcm_setup +if "%choice%"=="2" goto :pat_setup +if "%choice%"=="3" goto :ssh_setup +if "%choice%"=="4" goto :vscode_setup +if "%choice%"=="5" goto :store_setup + +echo ❌ Invalid choice. Please run the script again. +pause +exit /b 1 + +:gcm_setup +echo. +echo 🔑 Setting up Git Credential Manager... +echo. + +REM Check if GCM is installed +git-credential-manager --version >nul 2>&1 +if %errorlevel% neq 0 ( + echo ⚠️ Git Credential Manager not found + echo. + echo Installing Git Credential Manager... + echo. + + REM Try winget first + winget install --id GitHub.GitHubDesktop -e --source winget --silent + if %errorlevel% neq 0 ( + echo Winget failed. Please install manually: + echo Download: https://github.com/git-ecosystem/git-credential-manager/releases/latest + echo Or install GitHub Desktop which includes GCM + pause + exit /b 1 + ) + echo ✅ GitHub Desktop (includes GCM) installed +) + +REM Configure Git to use GCM +echo. +echo Configuring Git to use GCM... +git config --global credential.helper manager +echo ✅ GCM configured as credential helper +echo. +echo Next time you push/pull, GCM will open a browser for authentication +echo and securely store your credentials. +goto :end + +:pat_setup +echo. +echo 🔑 Setting up Personal Access Token... +echo. + +echo For git.d-popov.com, you'll need to: +echo 1. Go to your Git server web interface +echo 2. Generate a Personal Access Token +echo 3. Use your username + token as password +echo. + +REM Configure Git to store credentials +git config --global credential.helper store +echo ✅ Git configured to store credentials +echo. +echo Next time you push/pull: +echo - Username: Your Git username +echo - Password: [your personal access token] +echo - Git will remember these credentials +goto :end + +:ssh_setup +echo. +echo 🔐 Setting up SSH Keys... +echo. + +if exist "%USERPROFILE%\.ssh\id_ed25519" ( + echo ✅ SSH key already exists +) else ( + echo Generating new SSH key... + ssh-keygen -t ed25519 -C "git-credentials" -f "%USERPROFILE%\.ssh\id_ed25519" -N "" + echo ✅ SSH key generated +) + +echo. +echo 📋 SSH Public Key (add this to your Git server): +echo ---------------------------------------- +type "%USERPROFILE%\.ssh\id_ed25519.pub" +echo ---------------------------------------- +echo. +echo Next steps: +echo 1. Copy the public key above +echo 2. Add it to your Git server (git.d-popov.com) +echo 3. Test SSH connection: ssh -T git@git.d-popov.com +echo. + +REM Ask if user wants to change remote URL to SSH +set /p change_remote="Change remote URL to SSH? (y/n): " +if /i "%change_remote%"=="y" ( + for /f "tokens=*" %%i in ('git remote get-url origin') do set current_url=%%i + set ssh_url=%current_url:https://git.d-popov.com/=git@git.d-popov.com:% + git remote set-url origin "%ssh_url%" + echo ✅ Remote URL changed to SSH: %ssh_url% +) +goto :end + +:vscode_setup +echo. +echo 💻 Setting up VS Code Git Integration... +echo. + +REM Configure VS Code as credential helper +git config --global credential.helper vscode +echo ✅ VS Code configured as credential helper +echo. +echo Next time you use Git in VS Code: +echo - VS Code will prompt for credentials +echo - Choose 'Save' to store them +echo - Credentials are stored securely +goto :end + +:store_setup +echo. +echo 💾 Setting up credential storage... +echo. + +echo ⚠️ WARNING: This stores credentials in plain text! +echo This is less secure than other methods. +echo. + +set /p confirm="Continue anyway? (y/n): " +if /i not "%confirm%"=="y" goto :end + +git config --global credential.helper store +echo ✅ Git configured to store credentials +echo. +echo Your credentials will be stored in plain text. +echo Make sure your computer is secure! +goto :end + +:end +echo. +echo 🎉 Git credential setup complete! +echo. +echo 📖 Additional Resources: +echo - Git Documentation: https://git-scm.com/doc +echo - GCM Documentation: https://aka.ms/gcm +echo - SSH Key Guide: https://docs.github.com/en/authentication/connecting-to-github-with-ssh +echo. +echo 🧪 Test your setup: +echo git fetch +echo git pull +echo git push +echo. +pause diff --git a/rin/miner/setup-git-credentials.ps1 b/rin/miner/setup-git-credentials.ps1 new file mode 100644 index 0000000..707a1bb --- /dev/null +++ b/rin/miner/setup-git-credentials.ps1 @@ -0,0 +1,253 @@ +# Git Credential Setup for Windows 11 +# Comprehensive setup script for managing Git credentials + +Write-Host "" +Write-Host "🔐 Git Credential Setup for Windows 11" -ForegroundColor Cyan +Write-Host "====================================" -ForegroundColor Cyan +Write-Host "" + +# Check if Git is installed +try { + $gitVersion = git --version 2>$null + Write-Host "✅ Git found: $gitVersion" -ForegroundColor Green +} catch { + Write-Host "❌ Error: Git is not installed" -ForegroundColor Red + Write-Host "" + Write-Host "Please install Git for Windows:" -ForegroundColor Yellow + Write-Host "Download: https://gitforwindows.org/" -ForegroundColor White + Write-Host "Or via winget: winget install --id Git.Git -e --source winget" -ForegroundColor White + Read-Host "Press Enter to exit" + exit 1 +} + +# Check current Git config +Write-Host "📋 Current Git Configuration:" -ForegroundColor Magenta +Write-Host "User Name: $(git config --global user.name)" -ForegroundColor White +Write-Host "User Email: $(git config --global user.email)" -ForegroundColor White +Write-Host "Credential Helper: $(git config --global credential.helper)" -ForegroundColor White +Write-Host "" + +# Check if we're in a Git repository +if (Test-Path ".git") { + Write-Host "📁 Current Repository:" -ForegroundColor Magenta + $remoteUrl = git remote get-url origin 2>$null + Write-Host "Remote URL: $remoteUrl" -ForegroundColor White + Write-Host "" +} + +Write-Host "🔧 Available Git Credential Methods:" -ForegroundColor Yellow +Write-Host "1. Git Credential Manager (Recommended)" -ForegroundColor White +Write-Host "2. GitHub CLI (for GitHub/GitLab)" -ForegroundColor White +Write-Host "3. SSH Keys (Most Secure)" -ForegroundColor White +Write-Host "4. Personal Access Token" -ForegroundColor White +Write-Host "5. VS Code Integration" -ForegroundColor White +Write-Host "" + +$choice = Read-Host "Choose your preferred method (1-5)" + +switch ($choice) { + "1" { + Write-Host "" + Write-Host "🔑 Setting up Git Credential Manager (GCM)..." -ForegroundColor Green + Write-Host "" + + # Check if GCM is installed + $gcmInstalled = $false + try { + $gcmVersion = git-credential-manager --version 2>$null + $gcmInstalled = $true + Write-Host "✅ Git Credential Manager found: $gcmVersion" -ForegroundColor Green + } catch { + Write-Host "⚠️ Git Credential Manager not found" -ForegroundColor Yellow + } + + if (-not $gcmInstalled) { + Write-Host "" + Write-Host "Installing Git Credential Manager..." -ForegroundColor Yellow + + # Try winget first + try { + Write-Host "Trying winget..." -ForegroundColor Gray + winget install --id GitHub.GitHubDesktop -e --source winget --silent + Write-Host "✅ GitHub Desktop (includes GCM) installed" -ForegroundColor Green + } catch { + Write-Host "Winget failed, trying manual download..." -ForegroundColor Yellow + + # Manual download + $gcmUrl = "https://github.com/git-ecosystem/git-credential-manager/releases/latest/download/gcm-win-x86-64.exe" + $installerPath = "$env:TEMP\gcm-installer.exe" + + Write-Host "Downloading GCM installer..." -ForegroundColor Gray + Invoke-WebRequest -Uri $gcmUrl -OutFile $installerPath + + Write-Host "Installing GCM..." -ForegroundColor Gray + Start-Process -FilePath $installerPath -ArgumentList "/VERYSILENT /NORESTART" -Wait + + Remove-Item $installerPath -Force + Write-Host "✅ Git Credential Manager installed" -ForegroundColor Green + } + } + + # Configure Git to use GCM + Write-Host "" + Write-Host "Configuring Git to use GCM..." -ForegroundColor Yellow + git config --global credential.helper manager + + Write-Host "✅ GCM configured as credential helper" -ForegroundColor Green + Write-Host "" + Write-Host "Next time you push/pull, GCM will:" -ForegroundColor Cyan + Write-Host "1. Open a browser for authentication" -ForegroundColor White + Write-Host "2. Store credentials securely" -ForegroundColor White + Write-Host "3. Handle token refresh automatically" -ForegroundColor White + } + + "2" { + Write-Host "" + Write-Host "🐙 Setting up GitHub CLI..." -ForegroundColor Green + Write-Host "" + + # Check if GitHub CLI is installed + $ghInstalled = $false + try { + $ghVersion = gh --version 2>$null | Select-Object -First 1 + $ghInstalled = $true + Write-Host "✅ GitHub CLI found: $ghVersion" -ForegroundColor Green + } catch { + Write-Host "⚠️ GitHub CLI not found" -ForegroundColor Yellow + } + + if (-not $ghInstalled) { + Write-Host "" + Write-Host "Installing GitHub CLI..." -ForegroundColor Yellow + try { + winget install --id GitHub.cli -e --source winget + Write-Host "✅ GitHub CLI installed" -ForegroundColor Green + } catch { + Write-Host "Please install GitHub CLI manually:" -ForegroundColor Yellow + Write-Host "Download: https://cli.github.com/" -ForegroundColor White + Read-Host "Press Enter after installation" + } + } + + # Authenticate with GitHub + Write-Host "" + Write-Host "Authenticating with GitHub..." -ForegroundColor Yellow + gh auth login + + # Configure Git to use GitHub CLI + Write-Host "" + Write-Host "Configuring Git to use GitHub CLI..." -ForegroundColor Yellow + git config --global credential.helper gh + + Write-Host "✅ GitHub CLI configured as credential helper" -ForegroundColor Green + } + + "3" { + Write-Host "" + Write-Host "🔐 Setting up SSH Keys (Most Secure)..." -ForegroundColor Green + Write-Host "" + + $sshKeyPath = "$env:USERPROFILE\.ssh\id_ed25519" + $sshKeyExists = Test-Path $sshKeyPath + + if ($sshKeyExists) { + Write-Host "✅ SSH key already exists at: $sshKeyPath" -ForegroundColor Green + } else { + Write-Host "Generating new SSH key..." -ForegroundColor Yellow + ssh-keygen -t ed25519 -C "$(git config --global user.email)" -f $sshKeyPath -N '""' + + Write-Host "✅ SSH key generated" -ForegroundColor Green + } + + Write-Host "" + Write-Host "📋 SSH Public Key (add this to your Git server):" -ForegroundColor Yellow + Write-Host "----------------------------------------" -ForegroundColor Gray + Get-Content "$sshKeyPath.pub" + Write-Host "----------------------------------------" -ForegroundColor Gray + + Write-Host "" + Write-Host "Next steps:" -ForegroundColor Cyan + Write-Host "1. Copy the public key above" -ForegroundColor White + Write-Host "2. Add it to your Git server (git.d-popov.com)" -ForegroundColor White + Write-Host "3. Test SSH connection: ssh -T git@git.d-popov.com" -ForegroundColor White + + # Change remote URL to SSH + $currentRemote = git remote get-url origin 2>$null + if ($currentRemote -and $currentRemote.StartsWith("https://")) { + Write-Host "" + $useSSH = Read-Host "Change remote URL to SSH? (y/n)" + if ($useSSH -eq "y") { + $sshUrl = $currentRemote -replace "https://git\.d-popov\.com/", "git@git.d-popov.com:" + $sshUrl = $sshUrl -replace "\.git$", ".git" + git remote set-url origin $sshUrl + Write-Host "✅ Remote URL changed to SSH: $sshUrl" -ForegroundColor Green + } + } + } + + "4" { + Write-Host "" + Write-Host "🔑 Setting up Personal Access Token..." -ForegroundColor Green + Write-Host "" + + Write-Host "For git.d-popov.com, you'll need to:" -ForegroundColor Yellow + Write-Host "1. Go to your Git server web interface" -ForegroundColor White + Write-Host "2. Generate a Personal Access Token" -ForegroundColor White + Write-Host "3. Use your username + token as password" -ForegroundColor White + Write-Host "" + + # Configure Git to store credentials + git config --global credential.helper store + + Write-Host "✅ Git configured to store credentials" -ForegroundColor Green + Write-Host "" + Write-Host "Next time you push/pull:" -ForegroundColor Cyan + Write-Host "- Username: $(git config --global user.name)" -ForegroundColor White + Write-Host "- Password: [your personal access token]" -ForegroundColor White + Write-Host "- Git will remember these credentials" -ForegroundColor White + } + + "5" { + Write-Host "" + Write-Host "💻 Setting up VS Code Git Integration..." -ForegroundColor Green + Write-Host "" + + Write-Host "VS Code has built-in Git credential management:" -ForegroundColor Yellow + Write-Host "1. VS Code stores credentials securely" -ForegroundColor White + Write-Host "2. No additional setup needed" -ForegroundColor White + Write-Host "3. Credentials are managed per-repository" -ForegroundColor White + Write-Host "" + + # Configure VS Code as credential helper + git config --global credential.helper vscode + + Write-Host "✅ VS Code configured as credential helper" -ForegroundColor Green + Write-Host "" + Write-Host "Next time you use Git in VS Code:" -ForegroundColor Cyan + Write-Host "- VS Code will prompt for credentials" -ForegroundColor White + Write-Host "- Choose 'Save' to store them" -ForegroundColor White + Write-Host "- Credentials are stored securely" -ForegroundColor White + } + + default { + Write-Host "❌ Invalid choice. Please run the script again." -ForegroundColor Red + exit 1 + } +} + +Write-Host "" +Write-Host "🎉 Git credential setup complete!" -ForegroundColor Green +Write-Host "" +Write-Host "📖 Additional Resources:" -ForegroundColor Magenta +Write-Host "- Git Documentation: https://git-scm.com/doc" -ForegroundColor White +Write-Host "- GCM Documentation: https://aka.ms/gcm" -ForegroundColor White +Write-Host "- SSH Key Guide: https://docs.github.com/en/authentication/connecting-to-github-with-ssh" -ForegroundColor White +Write-Host "" + +Write-Host "🧪 Test your setup:" -ForegroundColor Yellow +Write-Host "git fetch" -ForegroundColor White +Write-Host "git pull" -ForegroundColor White +Write-Host "git push" -ForegroundColor White +Write-Host "" + +Read-Host "Press Enter to continue" diff --git a/rin/miner/test-git-credentials-linux.sh b/rin/miner/test-git-credentials-linux.sh new file mode 100644 index 0000000..75299a2 --- /dev/null +++ b/rin/miner/test-git-credentials-linux.sh @@ -0,0 +1,156 @@ +#!/bin/bash +# Git Credentials Test Script for Linux Mint + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +PURPLE='\033[0;35m' +CYAN='\033[0;36m' +NC='\033[0m' # No Color + +print_header() { + echo -e "${CYAN}🧪 Git Credentials Test${NC}" + echo -e "${CYAN}======================${NC}" + echo "" +} + +print_success() { + echo -e "${GREEN}✅ $1${NC}" +} + +print_error() { + echo -e "${RED}❌ $1${NC}" +} + +print_warning() { + echo -e "${YELLOW}⚠️ $1${NC}" +} + +print_info() { + echo -e "${PURPLE}ℹ️ $1${NC}" +} + +# Main script +print_header + +# Check if we're in a Git repository +if [ ! -d ".git" ]; then + print_error "Not in a Git repository. Please run from the repository root." + exit 1 +fi + +# Get repository info +print_info "Repository Information:" +echo "Remote URL: $(git remote get-url origin 2>/dev/null || echo 'No remote')" +echo "Current Branch: $(git branch --show-current 2>/dev/null || echo 'No branch')" +echo "" + +# Check Git configuration +print_info "Git Configuration:" +echo "User Name: $(git config --global user.name 2>/dev/null || echo 'Not set')" +echo "User Email: $(git config --global user.email 2>/dev/null || echo 'Not set')" +echo "Credential Helper: $(git config --global credential.helper 2>/dev/null || echo 'Not set')" +echo "" + +# Test credential helper +credential_helper=$(git config --global credential.helper 2>/dev/null || echo "") + +print_info "Testing Credential Setup:" +case $credential_helper in + "cache") + print_success "Using Git credential cache" + echo " Credentials cached temporarily (default: 15 minutes)" + ;; + "store") + print_warning "Using Git credential store (plain text)" + echo " Credentials stored in: ~/.git-credentials" + ;; + "libsecret") + print_success "Using GNOME Keyring (encrypted)" + echo " Credentials stored securely in keyring" + ;; + "vscode") + print_success "Using VS Code credential helper" + echo " VS Code manages credentials securely" + ;; + "") + print_error "No credential helper configured" + echo " Run ./setup-git-credentials-linux.sh to configure" + ;; + *) + print_info "Using custom credential helper: $credential_helper" + ;; +esac + +# Check SSH keys if using SSH remote +remote_url=$(git remote get-url origin 2>/dev/null || echo "") +if [[ $remote_url == git@* ]]; then + echo "" + print_info "SSH Key Check:" + + ssh_key_path="$HOME/.ssh/id_ed25519" + if [ -f "$ssh_key_path" ]; then + print_success "SSH key found at: $ssh_key_path" + + # Test SSH connection + echo "Testing SSH connection to git.d-popov.com..." + if ssh -T git@git.d-popov.com "echo 'SSH connection successful'" 2>/dev/null; then + print_success "SSH connection to git.d-popov.com works" + else + print_error "SSH connection failed" + echo " Make sure your public key is added to git.d-popov.com" + echo " Test manually: ssh -T git@git.d-popov.com" + fi + else + print_error "SSH key not found at: $ssh_key_path" + echo " Run ./setup-git-credentials-linux.sh and choose SSH option" + fi +fi + +# Test Git operations +echo "" +print_info "Testing Git Operations:" + +echo -n "git fetch: " +if git fetch --quiet 2>/dev/null; then + print_success "Success" +else + print_error "Failed" +fi + +echo -n "git status: " +if git status --porcelain >/dev/null 2>&1; then + print_success "Success" +else + print_error "Failed" +fi + +# Summary and recommendations +echo "" +print_info "Summary & Recommendations:" + +if [ -z "$credential_helper" ]; then + print_error "No credential helper configured" + echo " → Run ./setup-git-credentials-linux.sh" +elif [ "$credential_helper" = "store" ]; then + print_warning "Using plain text credential storage" + echo " → Consider switching to SSH keys or GNOME Keyring" +elif [[ $remote_url == git@* ]] && [ ! -f "$HOME/.ssh/id_ed25519" ]; then + print_warning "Using SSH but no SSH key found" + echo " → Set up SSH keys for passwordless authentication" +else + print_success "Credential setup looks good!" + echo " → You should be able to push/pull without prompts" +fi + +echo "" +print_info "Troubleshooting Commands:" +echo "• Clear stored credentials: git config --global --unset credential.helper" +echo "• Reset credential helper: ./setup-git-credentials-linux.sh" +echo "• Test SSH: ssh -T git@git.d-popov.com" +echo "• Check Git config: git config --list --show-origin" +echo "• Clear credential cache: git config --global --unset-all credential.helper" diff --git a/rin/miner/test-git-credentials.ps1 b/rin/miner/test-git-credentials.ps1 new file mode 100644 index 0000000..01bdb42 --- /dev/null +++ b/rin/miner/test-git-credentials.ps1 @@ -0,0 +1,151 @@ +# Git Credentials Test Script +# Tests your Git credential setup and provides troubleshooting + +Write-Host "" +Write-Host "🧪 Git Credentials Test" -ForegroundColor Cyan +Write-Host "======================" -ForegroundColor Cyan +Write-Host "" + +# Check Git installation +try { + $gitVersion = git --version + Write-Host "✅ Git: $gitVersion" -ForegroundColor Green +} catch { + Write-Host "❌ Git not found. Please install Git for Windows." -ForegroundColor Red + Write-Host "Download: https://gitforwindows.org/" -ForegroundColor Yellow + exit 1 +} + +# Check if we're in a Git repository +if (-not (Test-Path ".git")) { + Write-Host "❌ Not in a Git repository. Please run from the repository root." -ForegroundColor Red + exit 1 +} + +# Get repository info +Write-Host "📁 Repository Information:" -ForegroundColor Magenta +$remoteUrl = git remote get-url origin +Write-Host "Remote URL: $remoteUrl" -ForegroundColor White +$branch = git branch --show-current +Write-Host "Current Branch: $branch" -ForegroundColor White +Write-Host "" + +# Check Git configuration +Write-Host "⚙️ Git Configuration:" -ForegroundColor Magenta +$userName = git config --global user.name +$userEmail = git config --global user.email +$credentialHelper = git config --global credential.helper + +Write-Host "User Name: $userName" -ForegroundColor White +Write-Host "User Email: $userEmail" -ForegroundColor White +Write-Host "Credential Helper: $credentialHelper" -ForegroundColor White +Write-Host "" + +# Test credential helper +Write-Host "🔍 Testing Credential Setup:" -ForegroundColor Magenta + +switch ($credentialHelper) { + "manager" { + Write-Host "✅ Using Git Credential Manager (GCM)" -ForegroundColor Green + Write-Host " GCM will open a browser for authentication" -ForegroundColor Gray + } + "gh" { + Write-Host "✅ Using GitHub CLI" -ForegroundColor Green + Write-Host " Make sure you're logged in: gh auth status" -ForegroundColor Gray + } + "vscode" { + Write-Host "✅ Using VS Code credential helper" -ForegroundColor Green + Write-Host " VS Code will prompt for credentials when needed" -ForegroundColor Gray + } + "store" { + Write-Host "⚠️ Using credential store (plain text)" -ForegroundColor Yellow + Write-Host " Credentials stored in plain text file" -ForegroundColor Gray + } + "" { + Write-Host "❌ No credential helper configured" -ForegroundColor Red + Write-Host " Run setup-git-credentials.ps1 to configure" -ForegroundColor Yellow + } + default { + Write-Host "ℹ️ Using custom credential helper: $credentialHelper" -ForegroundColor Blue + } +} + +# Check SSH keys if using SSH +if ($remoteUrl -match "^git@") { + Write-Host "" + Write-Host "🔐 SSH Key Check:" -ForegroundColor Magenta + + $sshKeyPath = "$env:USERPROFILE\.ssh\id_ed25519" + if (Test-Path $sshKeyPath) { + Write-Host "✅ SSH key found at: $sshKeyPath" -ForegroundColor Green + + # Test SSH connection + Write-Host "Testing SSH connection..." -ForegroundColor Gray + try { + $sshTest = ssh -T git@git.d-popov.com "echo 'SSH connection successful'" 2>$null + if ($LASTEXITCODE -eq 0) { + Write-Host "✅ SSH connection to git.d-popov.com works" -ForegroundColor Green + } else { + Write-Host "❌ SSH connection failed. Check your SSH key setup." -ForegroundColor Red + } + } catch { + Write-Host "❌ SSH test failed. Make sure SSH is installed." -ForegroundColor Red + } + } else { + Write-Host "❌ SSH key not found at: $sshKeyPath" -ForegroundColor Red + Write-Host " Run setup-git-credentials.ps1 and choose SSH option" -ForegroundColor Yellow + } +} + +# Test Git operations +Write-Host "" +Write-Host "🧪 Testing Git Operations:" -ForegroundColor Magenta + +Write-Host "Testing git fetch..." -ForegroundColor Gray +try { + git fetch --quiet + Write-Host "✅ git fetch successful" -ForegroundColor Green +} catch { + Write-Host "❌ git fetch failed: $($_.Exception.Message)" -ForegroundColor Red +} + +Write-Host "Testing git status..." -ForegroundColor Gray +try { + $status = git status --porcelain + Write-Host "✅ git status successful" -ForegroundColor Green + if ($status) { + Write-Host " Repository has uncommitted changes" -ForegroundColor Yellow + } else { + Write-Host " Working directory clean" -ForegroundColor Green + } +} catch { + Write-Host "❌ git status failed: $($_.Exception.Message)" -ForegroundColor Red +} + +# Summary and recommendations +Write-Host "" +Write-Host "📋 Summary & Recommendations:" -ForegroundColor Magenta + +if (-not $credentialHelper) { + Write-Host "❌ No credential helper configured" -ForegroundColor Red + Write-Host " → Run .\setup-git-credentials.ps1" -ForegroundColor Yellow +} elseif ($credentialHelper -eq "store") { + Write-Host "⚠️ Using plain text credential storage" -ForegroundColor Yellow + Write-Host " → Consider switching to SSH keys or GCM" -ForegroundColor Yellow +} elseif ($remoteUrl -match "^git@" -and -not (Test-Path "$env:USERPROFILE\.ssh\id_ed25519")) { + Write-Host "⚠️ Using SSH but no SSH key found" -ForegroundColor Yellow + Write-Host " → Set up SSH keys for passwordless authentication" -ForegroundColor Yellow +} else { + Write-Host "✅ Credential setup looks good!" -ForegroundColor Green + Write-Host " → You should be able to push/pull without prompts" -ForegroundColor Green +} + +Write-Host "" +Write-Host "🔧 Troubleshooting Commands:" -ForegroundColor Cyan +Write-Host "• Clear stored credentials: git config --global --unset credential.helper" -ForegroundColor White +Write-Host "• Reset credential helper: .\setup-git-credentials.ps1" -ForegroundColor White +Write-Host "• Test SSH: ssh -T git@git.d-popov.com" -ForegroundColor White +Write-Host "• Check Git config: git config --list --show-origin" -ForegroundColor White + +Write-Host "" +Read-Host "Press Enter to continue"