Registry / database / redis-ssh

redis-ssh

JSON →
library1.0.0jsnpmunverified

redis-ssh v1.0.0 establishes a Redis connection through an SSH tunnel using the ssh2 and redis packages. It wraps the SSH tunnel lifecycle and provides a simple connect() function that returns a Redis client and a close() method. This package simplifies connecting to a remote Redis instance behind a firewall without manual SSH port forwarding. Unlike full VPN solutions, it is lightweight and specific to Redis. The release cadence is ad-hoc with no recent updates; it is stable for its limited use case but not actively maintained.

npm install redis-ssh
INSTALL
IMPORT
SIG · REDIS-SSH
R
redis-ssh
databasejavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (connect function)
import Redis from 'redis-ssh'
const Redis = require('redis-ssh')
ESM-friendly; but package uses CommonJS exports. Both import styles work.
connect
const { connect } = require('redis-ssh')
Named export 'connect' is available via destructuring. No default export for connect only.

Connects to a Redis server through an SSH tunnel, sets a key, then closes the tunnel.

const Redis = require('redis-ssh'); const fs = require('fs'); async function main() { const { client, close } = await Redis.connect( { host: 'ssh.example.com', username: 'user', privateKey: fs.readFileSync('/path/to/key.pem'), }, { host: '127.0.0.1', port: 6379, password: 'redis-pass', } ); client.set('key', 'value', (err, reply) => { if (err) throw err; console.log(reply); close(); }); } main().catch(console.error);
Debug
Known issues
gotchaMissing close() call leaves SSH tunnel open, causing resource leaks.
fix
Always call close() after finishing Redis operations, preferably in a finally block.
affects: >=0.0.0
breakingsshConfig and redisConfig objects must follow ssh2 and redis package specs exactly.
fix
Refer to ssh2 and redis documentation for correct parameters.
affects: >=0.0.0
gotchaThe function returns { client, close }, not just a client.
fix
Destructure the returned object to access client and close.
affects: >=0.0.0
deprecatedThe redis package (v3+) is being replaced by @redis/client for ioredis-like API.
fix
Consider using ioredis with manual SSH tunneling via ssh2, or switch to a more maintained library.
affects: >=0.0.0
Errors
Common errors & fixes
Error: connect ECONNREFUSED 127.0.0.1:6379
SSH tunnel not set up correctly or Redis is not running on the remote end.
fix
Verify sshConfig credentials and that Redis is listening on the remote host and port.
TypeError: Redis.connect is not a function
Import style mismatch; using default import when CommonJS require is expected, or vice versa.
fix
Use const Redis = require('redis-ssh'); then Redis.connect().
Error: All configured authentication methods failed
SSH authentication failure (bad key, username, or host).
fix
Check SSH private key path, permissions, username, and host.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
ssh2requiredrequired for SSH tunnel creation
redisrequiredrequired for Redis client
Agent activity
22 hits · last 30 days
node
18
Meta
1
Amazon
1
OpenAI (training)
1
Resources
redis-ssh — npm install redis-ssh · libregistry