Skip to content

Instantly share code, notes, and snippets.

@vol4ok
Created June 7, 2013 09:01
Show Gist options
  • Save vol4ok/5727997 to your computer and use it in GitHub Desktop.
Save vol4ok/5727997 to your computer and use it in GitHub Desktop.
share local server to remote server via ssh
LOCAL_PORT = 3333
REMOTE_PORT = 2222
SSH_USER_HOST = "foo@var.com"
express = require "express"
{spawn} = require "child_process"
ssh = spawn('ssh', ['-N', '-R', "#{REMOTE_PORT}:localhost:#{LOCAL_PORT}", SSH_USER_HOST])
app = express()
.use(express.favicon())
.use(express.bodyParser())
.use(express.logger("short"))
app.get "/", (req, res) ->
res.send("Hello world! I'm a local webserver! Woooooo!")
app.get "/exit", (req, res) ->
res.send("BYE!")
ssh.kill()
srv.close()
srv = app.listen(LOCAL_PORT)
@vol4ok
Copy link
Author

vol4ok commented Jun 7, 2013

add GatewayPorts yes to your sshd_config to allow binding to remote sockets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment