I have some trouble with connecting Erlang nodes on remote machine. And I found following solution:
Erlang (or erlang shell) should be started with same cookie on remote machines, i.e.:
erl -name node1 -setcookie my-cookie
erl -name node2 -setcookie my-cookie