Smart SSH Connection & Port Forwarding Manager
Save and manage SSH connections with port forwards. Never type long SSH commands again!
- πΎ Save SSH Profiles - Store connection details (host, user, port, key)
- π Quick Connect - Connect with a simple name instead of typing full SSH commands
- π‘ Port Forwarding - Manage local and remote port forwards
- π SSH Key Support - Use SSH keys for authentication
- π Profile Management - List, update, and delete profiles
- π Active Tracking - Monitor active background connections
- β Zero Dependencies - Pure Python, works everywhere
# Clone or download
git clone https://github.com/DonkRonk17/PortManager.git
cd PortManager
# Make executable (Unix/Mac)
chmod +x portmanager.py
# Run
python portmanager.py --help# Add an SSH profile
python portmanager.py add myserver user@example.com
# Add profile with SSH key
python portmanager.py add myserver user@example.com --key ~/.ssh/id_rsa --port 2222
# Add port forward to profile
python portmanager.py forward myserver 8080 80
# Connect using profile
python portmanager.py connect myserver
# List all profiles
python portmanager.py list# Basic profile
python portmanager.py add myserver user@example.com
# With custom port
python portmanager.py add myserver user@example.com --port 2222
# With SSH key
python portmanager.py add myserver user@example.com --key ~/.ssh/id_rsa
# All options
python portmanager.py add myserver user@example.com --port 2222 --key ~/.ssh/my_keyLocal Port Forward (Access remote service locally):
# Forward local:8080 to remote:80
python portmanager.py forward myserver 8080 80
# Forward to specific remote host
python portmanager.py forward myserver 3306 3306 --host db.internalRemote Port Forward (Expose local service remotely):
# Expose local:3000 on remote:3000
python portmanager.py forward myserver 3000 3000 --remoteCommon Use Cases:
# Access remote database locally
python portmanager.py forward prod-db 5432 5432
# Access remote web server
python portmanager.py forward web-server 8080 80
# Access internal service through bastion
python portmanager.py forward bastion 9200 9200 --host elasticsearch.internalInteractive Connection:
python portmanager.py connect myserverBackground Connection (with port forwards):
python portmanager.py connect myserver --backgroundList All Profiles:
python portmanager.py listOutput example:
π Saved Profiles (3):
prod-db
Connection: admin@db.example.com:22
Auth: Key: ~/.ssh/prod_key
Forwards:
L: localhost:5432 β localhost:5432
Last used: 2026-01-15 10:30
web-server
Connection: deploy@web.example.com:2222
Auth: Password
Last used: never
Delete a Profile:
python portmanager.py delete myserverShow Active Background Connections:
python portmanager.py active# Save production database profile
python portmanager.py add prod-db admin@db.production.com --key ~/.ssh/prod_key
# Add port forward
python portmanager.py forward prod-db 5432 5432
# Connect (now you can access postgres at localhost:5432)
python portmanager.py connect prod-db --background
# Use with psql
psql -h localhost -p 5432 -U admin mydb# Save bastion host
python portmanager.py add bastion ops@bastion.company.com --key ~/.ssh/company_key
# Forward multiple internal services
python portmanager.py forward bastion 9200 9200 --host elasticsearch.internal
python portmanager.py forward bastion 5601 5601 --host kibana.internal
python portmanager.py forward bastion 3000 3000 --host grafana.internal
# Connect once, access all services
python portmanager.py connect bastion --background
# Now access:
# - Elasticsearch: http://localhost:9200
# - Kibana: http://localhost:5601
# - Grafana: http://localhost:3000# Save dev server
python portmanager.py add dev-server yourname@dev.company.com
# Forward common dev ports
python portmanager.py forward dev-server 3000 3000 # React/Node
python portmanager.py forward dev-server 8080 8080 # Backend API
python portmanager.py forward dev-server 5432 5432 # PostgreSQL
# Quick connect
python portmanager.py connect dev-serverPortManager stores profiles in:
- Windows:
C:\Users\<username>\.portmanager\ - Mac/Linux:
~/.portmanager/
Files:
profiles.json- Saved SSH profilesactive_connections.json- Active background connections
- SSH keys are referenced, not stored
- Passwords are not stored (use SSH keys!)
- Profiles stored in plain JSON (chmod 600 recommended)
- Always use SSH keys for production systems
Works on:
- β Windows (via OpenSSH or PuTTY)
- β macOS (built-in SSH)
- β Linux (all distributions)
Requirements:
- Python 3.6+
- SSH client installed (
sshcommand available)
# List all profiles to see available names
python portmanager.py list# Make sure SSH key is added to ssh-agent
ssh-add ~/.ssh/your_key
# Or specify key explicitly when adding profile
python portmanager.py add myserver user@host --key ~/.ssh/your_key# Check if port forward is already active
python portmanager.py active
# Or check system processes
netstat -an | grep <port># Test SSH connection manually first
ssh -v user@host
# Check if host is reachable
ping host# Add to ~/.bashrc or ~/.zshrc
alias pm='python /path/to/portmanager.py'
alias pmc='python /path/to/portmanager.py connect'
alias pml='python /path/to/portmanager.py list'
# Now use:
pm list
pmc myserver# Add to $PROFILE
function pm { python C:\path\to\portmanager.py $args }
function pmc { python C:\path\to\portmanager.py connect $args }
# Now use:
pm list
pmc myserver# Web server with standard ports
python portmanager.py add web user@host --port 22
python portmanager.py forward web 80 80
python portmanager.py forward web 443 443
# Database server
python portmanager.py add db user@host --key ~/.ssh/db_key
python portmanager.py forward db 5432 5432 # PostgreSQL
python portmanager.py forward db 3306 3306 # MySQL
python portmanager.py forward db 27017 27017 # MongoDB| Command | Description | Example |
|---|---|---|
add |
Add/update SSH profile | pm add name user@host |
list |
List all profiles | pm list |
delete |
Delete a profile | pm delete name |
forward |
Add port forward | pm forward name 8080 80 |
connect |
Connect to server | pm connect name |
active |
Show active connections | pm active |
--port PORT- SSH port (default: 22)--key PATH- Path to SSH private key
--host HOST- Remote host (default: localhost)--remote- Remote forward instead of local
--background/-b- Run in background
Issues and pull requests welcome! This project is part of the AutoProjects suite.
MIT License - see LICENSE file for details
Part of the AutoProjects suite:
Created by Randell Logan Smith and Team Brain at Metaphy LLC
Part of the HMSS (Heavenly Morning Star System) ecosystem.
Created by: Holy Grail Automation
Version: 1.0.0
Zero Dependencies | Cross-Platform | Open Source