How do you connect through a node through ssh

For using :observer.start i’m looking for a way to connect from my development machine to a remote node through ssh with proxy. Because the domain we use it only for internal use on our server platform.

When we where using -sname when starting the server I was able to connect to the remote host.

Before with sname I was able to make it work by doing

epmd -names on the remote
Port in epmd -names around localhost
ssh -L4369:localhost:4369 -L39974:localhost:39974 edge@node2.host.example

Then locally I did
iex --sname debug --cookie cookie -S mix
Node.connect(:sname)

But with name even when adding both
node2 and node2.host.example in host file
iex --name debug --cookie cookie -S mix
when I do Node.connect(:“edge@node2.host.example”) it fails.

1 Like

If I understand you right, you used the first line to start IEX and the second inside of iex? Well, if you had posted the errormessage you got, it would probably tell, that either :sname is not a known node, or that you used another name when testing it…

When using shortnames, you need to Node.connect(:"edge@node2") and the FQDN when using long_names, at least if I recall correctly.

When we used short names I was able to get it to work. But now we use long names I’m not able to get it working again.
Don’t get any error message just a false when I try to connect.

When using longnames, of course you have to use longnames, eg: :"foo@server.example.com".

The last time I had to work with distributed Nodes, I was able to simply use the IP-addresses in the host part as in :"foo@127.0.0.1". I’m not sure though if I had to start them with a certain argument to make it work or if that works automatically.

I actually use Xforwarding to open the observer, it is easier:

# ~/.ssh/config
Host ci
  Hostname 192.168.1.100
  User danny
  ForwardX11 yes
  ForwardX11Trusted yes
1 Like

Ditto, I even include a little shell script for opening an observer into my prod build too:

╰─➤  cat observer_rel.sh 
#!/bin/sh

cookie=$(_build/prod/rel/my_server/bin/ccc_server describe | sed -n 's/.*cookie: *\(.*\)/\1/p')

iex --name observer@127.0.0.1 --hidden --cookie "$cookie" --remsh my_server@127.0.0.1 -e ':observer.start()'
1 Like

Are the names of your nodes also with @127.0.0.1 or do they use node@node1.example.com.
Because when I start I do see my local client, in epmd -names on the server
name observer at port 33388
name node at port 33388
But when I try to connect with Node.connect(:"node@127.0.0.1") on my local machine it gives false
And if I use the remsh it returns
Could not contact remote node node@127.0.0.1, reason: :nodedown

I start them explicitly with the machine name of 127.0.0.1 so I do not accidentally even expose them outside the machine (further reinforced by iptables and SELinux). All my connections are done over SSH tunnels. :slight_smile:

@minhajuddin and @OvermindDL1, this also means one has to install gtk/wx/other x-related things on the to-be-observed machine, right?

I am asking because my releases are currently running mostly on amazon linux without any x dependencies installed and I would like to use something like observer too to have some more tools for investigating issues.

If you run observer ‘on’ the remote machine then yeah, you need to be able to send an X session through, otherwise you can connect a new node over ssh and run it locally.

1 Like

@OvermindDL1 would you be able to share in more details what exactly needs to be set up to make this work?

I’ve been able to follow along with this guide to connect through an SSH tunnel, but it involves:

  1. a lot of manual typing
  2. hard-coded values that you need to look up again, as storing ports and the production cookie in a shell script seem like a very bad (insecure) idea.

What exactly do the X11-forwarding settings do? Are they part of the server SSH settings or your local machine’s? Does the server’s ERTS contain :observer, or is this not required when you remsh through the SSH tunnel?

1 Like

Uh, that is what I am doing, but it is on the server I’m connecting to anyway and not local, but then again this is a segregated network so… ^.^;

Server settings yep, it lets you run :observer, it’s not required if not going to run :observer.

1 Like

Ah, so you SSH into the server, and then run those commands on the server, which sends the X11 GUI windows through to your local machine using the established SSH connection?

(It still feels a bit like black magic to me :sweat_smile: )

Correct! Just enable X11 forwarding on the server, connect to it via ssh username@serveraddress -X then just use the distillery script to connect a shell to it then :observer.start() starts right up sending to the local system via the X11 protocol. It’s really easy once you get used to it, and it really is that simple. :slight_smile:

1 Like