Sets up a Redis connection inside an SSH tunnel.
sshConfig
should be an object according to thessh2
package.redisConfig
should be an object according to theredis
package.- Returns a Object, containing a
client
from theredis
package andclose
function.
Don't forget to close()
the tunnel connection when you're done with redis.
const Redis = require('redis-ssh');
async function main() {
const { client, close } = await Redis.connect(
{
host: '',
user: '',
privateKey: fs.readFileSync('./*.pem'),
},
{
host: '',
port: 0,
password: '',
}
);
client.doSomething('', function() {
close();
});
}