Skip to content

Instantly share code, notes, and snippets.

@ysmood
Last active January 20, 2016 07:03
Show Gist options
  • Select an option

  • Save ysmood/4a12a7c6b8e22b39450d to your computer and use it in GitHub Desktop.

Select an option

Save ysmood/4a12a7c6b8e22b39450d to your computer and use it in GitHub Desktop.
ssh proxy
var net = require("net");
var fromPort = 9000;
var toPort = 22;
var toHost = "127.0.0.1";
function errorLog (err) {
console.error(err);
}
var server = net.createServer(function (con) {
console.log("access:", con.address());
var to = net.connect(toPort, toHost);
con.setTimeout(0);
con.on("error", errorLog);
to.on("error", errorLog);
con.pipe(to);
to.pipe(con);
});
server.listen(fromPort);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment