carafe icon indicating copy to clipboard operation
carafe copied to clipboard

Safely connecting as hidden node

Open schnittchen opened this issue 8 years ago • 1 comments

I would love to see this feature, to make introspecting a node simple. It makes sense to have this in onartsipac:

  • we already know how to connect to a node via ssh
  • even though we do not maintain the erlang cookie, it is easy to obtain (1)
  • same for the node name as seen by epmd on the host (2)
  • the hidden node runs locally (so :observer is usually available), having run_locally makes this simple

Footnotes: (1)

      cookie = capture "bin/#{script}", "eval 'erlang:get_cookie().'"
      cookie = cookie[%r{\A'(.*)'\z}, 1].gsub("\'", "'")

(2)

      node_name = capture "bin/#{script}", "rpcterms Elixir.Node self"
      node_name = node_name[%r{\A'(.*)'\z}, 1].gsub("\'", "'")

schnittchen avatar Apr 23 '17 19:04 schnittchen

Though coupling a bit to how sshkit does things, this is how we can set up a forwarding:

with_ssh do |ssh| #yields a Net::SSH::Connection::Session
   ssh.forward.local(4369, "localhost", 4369)
   # ... 

Forwarding the detected node port leaves us with two alternatives:

  1. forward the exact same port from locally to the server. This implies that the server can never be the same as the local one, in particular, we cannot test the feature.
  2. run a fake epmd and set ERL_EPMD_PORT
  3. implement an epmd module, see https://www.erlang-solutions.com/blog/erlang-and-elixir-distribution-without-epmd.html

Both (2) and (3) look too complicated for the start.

schnittchen avatar Apr 23 '17 19:04 schnittchen