Secure sudo authentication for macOS CI/CD and automation
Ever tried to run sudo commands in macOS CI/CD pipelines and hit this error?
sudo: no tty present and no askpass program specified
macOS ASKPASS solves this by providing secure, automated sudo authentication for:
- β GitHub Actions workflows
- β Jenkins pipelines
- β Local development automation
- β Integration testing requiring root privileges
- β System configuration scripts
# Add the tap
brew tap scttfrdmn/macos-askpass
# Install askpass
brew install macos-askpasscurl -fsSL https://raw.githubusercontent.com/scttfrdmn/macos-askpass/main/install.sh | bashgit clone https://github.com/scttfrdmn/macos-askpass.git
cd macos-askpass
make install# Interactive setup (recommended for first-time users)
askpass setup
# Test functionality
askpass test
# Show configuration
askpass configGUI Mode (Interactive)
# Set up environment
export SUDO_ASKPASS=$(which askpass)
# Use with any sudo command - shows native macOS dialog
sudo -A systemsetup -getremotelogin # π₯οΈ GUI password dialog appears
sudo -A make install-deps # π₯οΈ GUI password dialog appearsCLI Mode (Automation)
# Store password in keychain (one-time setup)
askpass store
# Or use environment variable
export SUDO_PASSWORD="your_password"
export SUDO_ASKPASS=$(which askpass)
# Use with any sudo command - no dialogs
sudo -A ./integration-tests.sh # β‘ Automated, no prompts
sudo -A make install-system-deps # β‘ Automated, no promptsForce CLI Mode
# Disable GUI dialogs even in interactive environments
export ASKPASS_FORCE_CLI=1
export SUDO_ASKPASS=$(which askpass)
sudo -A echo "Always uses stored credentials" # π« No GUI dialog- name: Run integration tests
env:
CI_SUDO_PASSWORD: ${{ secrets.MACOS_SUDO_PASSWORD }}
run: |
export SUDO_ASKPASS=$(which askpass)
sudo -A make integration-testSecure password retrieval with intelligent priority system:
CI_SUDO_PASSWORD- CI/CD environment variable (highest priority)SUDO_PASSWORD- Local development environment variable- macOS Keychain - Secure local storage
- GUI Dialog - Native macOS password dialog (interactive environments)
- Terminal prompt - Fallback for TTY environments
- β No permanent password storage in files
- β macOS Keychain integration with access controls
- β Environment variable clearing after use
- β Input validation and sanitization
- β Secure file permissions (600)
- β Smart Mode Detection: Automatically chooses GUI or CLI based on environment
- β Zero Configuration: Works out of the box with environment variables
- β Interactive Setup: Guided configuration wizard
- β Native GUI: macOS password dialogs for interactive use
- β CLI Automation: Perfect for scripts and CI/CD
- β Comprehensive Help: Built-in documentation and examples
- β Debug Mode: Detailed logging for troubleshooting
- β GitHub Actions integration
- β Jenkins support
- β GitLab CI compatibility
- β Generic CI/CD system support
| Command | Description |
|---|---|
askpass |
Output password (ASKPASS mode) |
askpass setup |
Interactive configuration wizard |
askpass test |
Test functionality |
askpass config |
Show current configuration |
askpass store |
Store password in keychain |
askpass remove |
Remove stored password |
askpass version |
Show version information |
askpass help |
Show help message |
| Variable | Purpose | Priority |
|---|---|---|
CI_SUDO_PASSWORD |
CI/CD password | 1 (highest) |
SUDO_PASSWORD |
Local development password | 2 |
SUDO_ASKPASS |
Path to askpass program | Required |
ASKPASS_FORCE_CLI |
Disable GUI dialogs (set to 1) | Optional |
ASKPASS_DEBUG |
Enable debug logging | Optional |
name: macOS Integration Tests
on: [push, pull_request]
jobs:
test:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install askpass
run: |
curl -fsSL https://raw.githubusercontent.com/scttfrdmn/macos-askpass/main/install.sh | bash
- name: Run integration tests
env:
CI_SUDO_PASSWORD: ${{ secrets.MACOS_SUDO_PASSWORD }}
run: |
export SUDO_ASKPASS=$(which askpass)
sudo -A make integration-testpipeline {
agent { label 'macos' }
environment {
CI_SUDO_PASSWORD = credentials('macos-sudo-password')
SUDO_ASKPASS = '/usr/local/bin/askpass'
}
stages {
stage('Test') {
steps {
sh 'sudo -A make integration-test'
}
}
}
}# One-time setup
askpass setup
# Daily usage
export SUDO_ASKPASS=$(which askpass)
sudo -A ./run-tests.sh
sudo -A make install-system-deps# Test target that works in both local and CI environments
test-integration:
@if [ -z "$$SUDO_ASKPASS" ]; then \
export SUDO_ASKPASS=$$(which askpass); \
fi
sudo -A ./integration-tests.sh
setup-askpass:
@command -v askpass >/dev/null || { \
echo "Installing askpass..."; \
curl -fsSL https://raw.githubusercontent.com/scttfrdmn/macos-askpass/main/install.sh | bash; \
}
askpass setup# Solution: Set SUDO_ASKPASS environment variable
export SUDO_ASKPASS=$(which askpass)# Solution: Install askpass
curl -fsSL https://raw.githubusercontent.com/scttfrdmn/macos-askpass/main/install.sh | bash# Solution: Configure password source
askpass setup # Interactive setup
# OR set environment variable
export SUDO_PASSWORD="your_password"
# OR store in keychain
askpass storeEnable detailed logging:
export ASKPASS_DEBUG=1
askpass testSample debug output:
ASKPASS DEBUG: Called by sudo (PID: 12345)
ASKPASS DEBUG: User: username
ASKPASS DEBUG: Attempting password retrieval...
ASKPASS DEBUG: Using keychain password source
β
Password retrieval successful
# Test basic functionality
make test
# Test with environment variable
SUDO_PASSWORD="test" askpass test
# Test CI/CD mode
make test-ci TEST_PASSWORD="test"# Test with real sudo command
export SUDO_ASKPASS=$(which askpass)
sudo -A echo "ASKPASS working!"
# Test system integration
sudo -A systemsetup -getremotelogingit clone https://github.com/scttfrdmn/macos-askpass.git
cd macos-askpass
# Install locally
make install-local
# Run tests
make test
# Development cycle
make dev- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly:
make check - Submit a pull request
- macOS 10.14+ (Mojave or later)
- Bash 4.0+ (included with macOS)
- sudo privileges
- curl (for installation)
Network Testing
sudo -A pfctl -sr # Check firewall rules
sudo -A ifconfig bridge100 create # Create network bridgeSystem Configuration
sudo -A systemsetup -setremotelogin on
sudo -A launchctl load /Library/LaunchDaemons/service.plistPackage Management
sudo -A make install-deps
sudo -A installer -pkg package.pkg -target /Integration Testing
sudo -A ./test-network-config.sh
sudo -A ./test-system-integration.sh| Feature | macOS ASKPASS | ssh-askpass | Manual Scripts |
|---|---|---|---|
| CI/CD Ready | β Purpose-built | β GUI-focused | |
| Security | β Multi-source + Keychain | β Often insecure | |
| Documentation | β Comprehensive | β Minimal | β None |
| Maintenance | β Active | β Stale | β Per-project |
| macOS Integration | β Native | β Native |
MIT License - see LICENSE file for details.
Inspired by the need for secure macOS automation in CI/CD pipelines. Built for the developer community that runs into sudo authentication challenges in automated environments.
- GitHub: https://github.com/scttfrdmn/macos-askpass
- Issues: https://github.com/scttfrdmn/macos-askpass/issues
- Releases: https://github.com/scttfrdmn/macos-askpass/releases
Made with β€οΈ for the macOS developer community