feat: added a ssh utility that supports smart-aliases and background ssh
tunnels
This commit is contained in:
85
config/ansible/tasks/global/utils/smart-ssh/config.yaml
Normal file
85
config/ansible/tasks/global/utils/smart-ssh/config.yaml
Normal file
@@ -0,0 +1,85 @@
|
||||
# SSH Utility Configuration
|
||||
# This file defines smart aliases that automatically choose between local and remote connections
|
||||
|
||||
# Logging configuration
|
||||
logging:
|
||||
enabled: true
|
||||
# Levels: debug, info, warn, error
|
||||
level: "info"
|
||||
# Formats: console, json
|
||||
format: "console"
|
||||
|
||||
smart_aliases:
|
||||
# Desktop connection - tries local network first, falls back to Tailscale
|
||||
desktop:
|
||||
primary: "desktop-local" # Use this SSH config entry when local network is available
|
||||
fallback: "desktop" # Use this SSH config entry when local network is not available
|
||||
check_host: "192.168.86.22" # IP address to ping for connectivity test
|
||||
timeout: "2s" # Timeout for connectivity check
|
||||
|
||||
# Background SSH Tunnel Definitions
|
||||
tunnels:
|
||||
# Example: Desktop database tunnel
|
||||
desktop-database:
|
||||
type: local
|
||||
local_port: 5432
|
||||
remote_host: database
|
||||
remote_port: 5432
|
||||
ssh_host: desktop # Uses smart alias logic (desktop-local/desktop)
|
||||
|
||||
# Example: Development API tunnel
|
||||
dev-api:
|
||||
type: local
|
||||
local_port: 8080
|
||||
remote_host: api
|
||||
remote_port: 80
|
||||
ssh_host: dev-server
|
||||
|
||||
# Example: SOCKS proxy tunnel
|
||||
socks-proxy:
|
||||
type: dynamic
|
||||
local_port: 1080
|
||||
ssh_host: bastion
|
||||
|
||||
# Modem web interface tunnel
|
||||
modem-web:
|
||||
type: local
|
||||
local_port: 8443
|
||||
remote_host: 192.168.1.1
|
||||
remote_port: 443
|
||||
ssh_host: desktop
|
||||
# Tunnel Management Commands:
|
||||
# ssh --tunnel --open desktop-database (or ssh -TO desktop-database)
|
||||
# ssh --tunnel --close desktop-database (or ssh -TC desktop-database)
|
||||
# ssh --tunnel --list (or ssh -TL)
|
||||
#
|
||||
# Ad-hoc tunnels (not in config):
|
||||
# ssh -TO temp-api --local 8080:api:80 --via server
|
||||
|
||||
# Logging options:
|
||||
# - enabled: true/false - whether to show any logs
|
||||
# - level: debug (verbose), info (normal), warn (warnings only), error (errors only)
|
||||
# - format: console (human readable), json (structured)
|
||||
# Logs are written to stderr so they don't interfere with SSH output
|
||||
|
||||
# How it works:
|
||||
# 1. When you run: ssh desktop
|
||||
# 2. The utility pings 192.168.86.22 with a 2s timeout
|
||||
# 3. If ping succeeds: runs "ssh desktop-local" instead
|
||||
# 4. If ping fails: runs "ssh desktop" instead
|
||||
# 5. All other SSH usage (flags, user@host, etc.) passes through unchanged
|
||||
|
||||
# Your SSH config should contain the actual host definitions:
|
||||
# Host desktop
|
||||
# HostName mennos-cachyos-desktop
|
||||
# User menno
|
||||
# Port 400
|
||||
# ForwardAgent yes
|
||||
# AddKeysToAgent yes
|
||||
#
|
||||
# Host desktop-local
|
||||
# HostName 192.168.86.22
|
||||
# User menno
|
||||
# Port 400
|
||||
# ForwardAgent yes
|
||||
# AddKeysToAgent yes
|
Reference in New Issue
Block a user