tg command overview
Basic Connection Management
# Add a simple connection
tg add -n web-server -h 192.168.1.100 -u admin
# Add with custom port and SSH key
tg add -n database -h db.company.com -u dbuser -p 2222 -k ~/.ssh/db_key
# Interactive mode (prompts for all options)
tg add
# Clone an existing connection with a new name
tg clone prod-web staging-web
# Connect (updates last_used / use_count, then execs ssh)
tg connect prod-web
# Preview the SSH command without connecting
tg connect prod-web --dry-run
Listing and Filtering
# Standard table view
tg list
# Detailed view showing notes, proxy, and port forwarding
tg list --detailed
# Compact and JSON formats
tg list --format compact
tg list --format json
# Filter by tag
tg list --tag production
# Full-text search across name, host, user, and notes
tg list --search bastion
# Only connections never used
tg list --unused
# Sort by last used (most recent first)
tg list --sort last-used
# Combine filters
tg list --tag production --search web --sort use-count
ProxyJump (Bastion/Jump Servers)
# Simple bastion host access
tg add -n internal-server -h 10.0.1.100 -u admin \
--proxy-jump bastion.company.com
# Bastion with specific user and port
tg add -n secure-db -h 192.168.10.50 -u dbadmin \
--proxy-jump "jumpuser@bastion.company.com:2222"
# Multi-hop through multiple servers
tg add -n deep-internal -h 172.16.5.10 -u root \
--proxy-jump "jump1.company.com,user@jump2.internal.com"
Port Forwarding
# Local port forwarding (tunnel remote service to local port)
tg add -n mysql-tunnel -h db-server.company.com -u dbuser \
--local-forward "3306:localhost:3306"
# Multiple port forwards
tg add -n dev-services -h dev-server.company.com -u developer \
--local-forward "8080:localhost:80,3306:db-internal:3306,5432:pg-db:5432"
# Remote port forwarding (expose local service to remote)
tg add -n demo-server -h demo.company.com -u demo \
--remote-forward "8080:localhost:3000"
Export, Import, and Backup
# Export all connections to JSON (stdout)
tg export
# Save to a file
tg export -o backup.json
# Export as raw SSH config blocks
tg export --format ssh-config
# Export without key paths (safe to share)
tg export --strip-keys -o safe-backup.json
# Import from a backup (skip existing by default)
tg import backup.json
# Import and overwrite conflicts
tg import backup.json --strategy overwrite
# Import and auto-rename conflicts (prod-web → prod-web-2)
tg import backup.json --strategy rename
History, Health Checks, and Snippets
# Show recently used connections
tg history
# Show full history
tg history --all
# Test SSH connectivity for a single connection
tg test prod-web
# Test all connections
tg test --all
# Custom timeout
tg test prod-web --timeout 10
# Print the full SSH command for a connection
tg snippet staging-db
# Print the SSH config block
tg snippet staging-db --config
# Copy to clipboard (macOS)
tg snippet staging-db | pbcopy
Complex Real-World Examples
# Production database with full security
tg add -n prod-db \
--host prod-db-01.internal \
--user produser \
--key ~/.ssh/production_key \
--proxy-jump prod-bastion.company.com \
--local-forward "5432:prod-db-01.internal:5432" \
--notes "Production PostgreSQL via bastion"
# Development full-stack environment
tg add -n dev-full-stack \
--host dev.company.com \
--user developer \
--proxy-jump dev-bastion.company.com \
--local-forward "3000:localhost:3000,8080:localhost:8080,5432:localhost:5432" \
--notes "React (3000), API (8080), PostgreSQL (5432)"
# Clone prod config to staging and update the host
tg clone prod-db staging-db
tg update staging-db --host staging-db-01.internal --non-interactive
Connection Management
# Show detailed connection information
tg show prod-db
tg show 1 # By number from list
# Update a connection (non-interactive)
tg update prod-db --host 10.0.1.20 --non-interactive
# Add or replace tags
tg update prod-db --tags "production,database" --non-interactive
# Remove a connection
tg remove prod-db
tg remove prod-db --force # Skip confirmation
# View generated SSH configuration
cat ~/.ssh/config.tengingarstjori
CLI Commands
Connection Commands
| Command |
Description |
tg add |
Add a new SSH connection (interactive or via flags) |
tg update <name> |
Update fields on an existing connection |
tg clone <src> <name> |
Duplicate a connection with a new name |
tg remove <name> |
Remove a connection (--force skips confirmation) |
tg show <name> |
Show all fields and the generated SSH config block |
tg list |
List connections (--tag, --search, --sort, --unused, --format) |
Workflow Commands
| Command |
Description |
tg connect <name> |
Connect via SSH; updates usage stats (--dry-run to preview) |
tg snippet <name> |
Print the SSH command or config block (--config) |
tg history |
Show recently used connections (--all, -n <limit>) |
tg test <name> |
Check SSH connectivity (--all, --timeout) |
tg export |
Export connections to JSON or SSH config (-o, -f, --strip-keys) |
tg import <file> |
Import connections from JSON (--strategy skip|overwrite|rename) |
Setup & Maintenance Commands
| Command |
Description |
tg init |
Initialize and integrate with SSH config |
tg config |
Manage default settings (e.g. default SSH key) |
tg validate |
Check all connections for config issues |
tg refresh |
Regenerate ~/.ssh/config.tengingarstjori |
tg fix-config |
Repair corrupted Include lines |
tg fix-forwards |
Auto-correct old-style port forwarding syntax |
tg reset |
Restore original SSH config from backup |
File Locations
- Main SSH config:
~/.ssh/config
- Managed config:
~/.ssh/config.tengingarstjori
- Backup:
~/.ssh/config.backup
- Tengingarstjóri data:
~/.tengingarstjori/
- Connection database:
~/.tengingarstjori/connections.json
Development Commands
mise run test - Run tests with coverage
mise run lint - Check code quality
mise run format - Format code
mise run validate - Full validation suite
mise run validate:quick - Quick validation
Development Workflow
# Daily development workflow
mise run validate:quick # Quick checks before starting
# ... make changes ...
mise run test # Run tests with coverage
mise run lint # Check code quality
mise run validate # Full validation before commit