SSH Backend Connector
Secure SSH backend connection manager for applications with password protected encrypted key storage.
Features
- Secure AES-256-GCM encryption for SSH keys
- Password-based key derivation using scrypt
- Automatic cleanup of sensitive data
- Encrypted local storage of SSH keys and configurations
- SSH tunnel management
Install
npm install ssh-backend-connector
Usage
import { SSHStoreManager, SSHManager } from "ssh-backend-connector";
const store = new SSHStoreManager();
await store.connect("your-secure-password");
await store.saveKeyPair({
id: "prod-key",
name: "Production Server",
privateKey: "-----BEGIN RSA PRIVATE KEY-----...",
});
await store.saveBackend({
id: "prod",
name: "Production",
host: "192.168.1.100",
port: 22,
username: "admin",
keyPairId: "prod-key",
tunnels: [{ localPort: 1234, remotePort: 4321 }],
});
const ssh = new SSHManager(store);
await ssh.connect("prod");
ssh.disconnect("prod");
store.disconnect();
API
SSHStoreManager
connect(password: string)
: Initialize encryption with passworddisconnect()
: Clear sensitive data from memorysaveKeyPair(keyPair: SSHKeyPair)
: Store encrypted SSH key pairgetKeyPair(id: string)
: Retrieve and decrypt key pairgetAllKeyPairs()
: List all key pairsdeleteKeyPair(id: string)
: Remove key pairsaveBackend(backend: Backend)
: Store backend configurationgetBackend(id: string)
: Retrieve backend configgetAllBackends()
: List all backendsdeleteBackend(id: string)
: Remove backend config
SSHManager
constructor(store: SSHStoreManager)
: Create manager with storeconnect(backendId: string)
: Establish SSH connectiondisconnect(backendId: string)
: Close connection
Security
This package takes security seriously:
✓ Passwords must be at least 12 characters with complexity requirements
✓ Keys are encrypted using AES-256-GCM
✓ Sensitive data is automatically cleared from memory
✓ Password is never stored in memory
✓ Encryption is verified on connection
✓ Rate limiting on connection attempts
✓ Connection timeouts to prevent hanging
✓ Maximum concurrent connections limit
✓ File size limits to prevent DoS
✓ Secure file permissions (0600)
✓ Path traversal protection
Future Security Improvements
Here is a list of potential future work items in the security area:
Development
npm install
npm test
npm run build
License
MIT