217 lines
5.1 KiB
Markdown
217 lines
5.1 KiB
Markdown
# 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! 🎯
|