Erlang OTP: Distributed & Fault-Tolerant Systems Programming · Aula

Segurança da Distribuição e Cookies

Proteja a comunicação entre nós Erlang distribuídos usando cookies mágicos, nomes de nós e distribuição TLS.

Aula 4 de 413 etapas

Segurança da Distribuição e Cookies é uma aula grátis de Erlang OTP: Distributed & Fault-Tolerant Systems Programming no CoddyKit. Esta é a aula 4 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Erlang OTP: Distributed & Fault-Tolerant Systems Programming, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Erlang OTP: Distributed & Fault-Tolerant Systems Programming inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Trust in a Cluster

Connected Erlang nodes fully trust each other: any node can run code on any other. That power makes securing distribution essential.

The Magic Cookie

Each node has a secret cookie. Two nodes can only connect if their cookies match. It is the basic authentication mechanism for clustering.

erlang:get_cookie().
% => 'SECRETCOOKIE'

Setting the Cookie

You can set the cookie at startup or at runtime. All nodes that should cluster must share the same value.

% at startup:
% erl -setcookie SECRET -name node1@host

erlang:set_cookie(node(), 'SECRET').

The .erlang.cookie File

If not set explicitly, the VM reads ~/.erlang.cookie. It must have restrictive permissions or the VM refuses to start.

% chmod 400 ~/.erlang.cookie

Short vs Long Names

Nodes use -sname (short hostname) or -name (fully qualified). Both nodes must use the same scheme to connect.

% erl -sname worker
% erl -name worker@10.0.0.5

Cookies Are Not Encryption

A matching cookie only authenticates the connection. By default, traffic between nodes is unencrypted. On untrusted networks you need TLS.

TLS Distribution

Erlang can tunnel all inter-node traffic over TLS using the inet_tls_dist module, configured via a proto_dist flag and a certificate file.

% erl -proto_dist inet_tls \
%     -ssl_dist_optfile ssl_dist.conf \
%     -name node1@host

The ssl_dist Config

The config file points to your certificate, key, and CA so nodes mutually authenticate and encrypt.

[{server, [{certfile, "node.pem"},
           {keyfile, "node.key"},
           {cacertfile, "ca.pem"}]},
 {client, [{cacertfile, "ca.pem"}]}].

Restricting epmd Exposure

The Erlang Port Mapper Daemon (epmd) registers node ports. Never expose epmd or distribution ports to the public internet; firewall them or use a VPN.

Hidden Nodes

A node started with -hidden connects without joining the global mesh, useful for tools that should not be part of the cluster's full-trust topology.

% erl -hidden -name monitor@host

Security Checklist

For safe distribution:

  • Use a strong, unique cookie
  • Protect the cookie file (chmod 400)
  • Enable TLS on untrusted networks
  • Firewall epmd and distribution ports

Quick Check

Test your distribution security knowledge.

Recap

You learned to secure distributed Erlang.

  • Matching cookies authenticate nodes
  • Protect the .erlang.cookie file
  • Use TLS distribution for encryption
  • Firewall epmd and distribution ports
Grátis para começar

Aprenda Erlang com um tutor de IA — grátis

Escreva e execute código real no seu navegador, obtenha ajuda instantânea de um tutor de IA 24/7 e continue de onde parou na web ou no app.

Cursos
12
Aulas
48

Perguntas Frequentes

A aula “Segurança da Distribuição e Cookies” é grátis?

Sim — o texto completo de “Segurança da Distribuição e Cookies” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Erlang OTP: Distributed & Fault-Tolerant Systems Programming, atualize para CoddyKit PRO. O curso de Erlang OTP: Distributed & Fault-Tolerant Systems Programming inclui 4 aulas no total.

O que vou aprender em “Segurança da Distribuição e Cookies”?

Proteja a comunicação entre nós Erlang distribuídos usando cookies mágicos, nomes de nós e distribuição TLS. Você pratica Erlang OTP: Distributed & Fault-Tolerant Systems Programming com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Erlang OTP: Distributed & Fault-Tolerant Systems Programming?

Nenhuma experiência prévia é necessária. Erlang OTP: Distributed & Fault-Tolerant Systems Programming no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 4 de 4.

Quanto tempo leva a aula “Segurança da Distribuição e Cookies”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Erlang OTP: Distributed & Fault-Tolerant Systems Programming?

Sim. Cada aula de Erlang OTP: Distributed & Fault-Tolerant Systems Programming inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Configuração e comunicação entre nós
  2. Chamadas de procedimento remoto (RPC)
  3. Registro global de processos
  4. Segurança da Distribuição e Cookies
← Voltar para Erlang OTP: Distributed & Fault-Tolerant Systems Programming