Skip to content
This repository was archived by the owner on Feb 12, 2026. It is now read-only.

Add sshk script for SSH with API key forwarding#105

Draft
jbearak wants to merge 1 commit into
mainfrom
sshk
Draft

Add sshk script for SSH with API key forwarding#105
jbearak wants to merge 1 commit into
mainfrom
sshk

Conversation

@jbearak
Copy link
Copy Markdown
Collaborator

@jbearak jbearak commented Aug 24, 2025

Overview

This PR adds the sshk script - a smart SSH wrapper that securely forwards environment variables including API keys to remote hosts.

What it does

  • Automatic credential discovery: Scans for API keys from multiple sources (environment variables, macOS Keychain)
  • Secure forwarding: Uses SSH's built-in SendEnv mechanism for safe transport
  • Tmux support: Properly handles environment variables in tmux sessions
  • Hierarchical fallback: Environment → Keychain (specific MCP patterns) → Generic api_keys service

Key Features

  • Comprehensive input validation to prevent injection attacks
  • Support for multiple credential sources with clear precedence
  • Extensive logging and security auditing
  • Installation helper for ~/bin setup
  • Compatible with bash and zsh

Supported Credentials

  • GitHub tokens (GITHUB_TOKEN, GITHUB_PERSONAL_ACCESS_TOKEN, GH_TOKEN)
  • Atlassian credentials (API token, domain, email)
  • Bitbucket credentials (username, app password, workspace)
  • Custom credentials via generic "api_keys" keychain service

Security

  • All inputs and outputs are validated
  • No credentials exposed in process lists or logs
  • Uses SSH's secure SendEnv mechanism
  • Comprehensive security checks and logging

Usage

# Basic usage
sshk user@server.com

# With tmux support
sshk -t user@server.com

# Execute remote command
sshk user@server.com "echo \$GITHUB_TOKEN"

The script includes detailed help (sshk --help) and keychain setup instructions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant