Seguridad de la distribución y cookies
Proteja la comunicación entre nodos distribuidos de Erlang mediante magic cookies, nombres de nodo y distribución TLS.
Seguridad de la distribución y cookies es una lección gratuita de Erlang OTP: Distributed & Fault-Tolerant Systems Programming en CoddyKit. Esta es la lección 4 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Erlang OTP: Distributed & Fault-Tolerant Systems Programming, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Erlang OTP: Distributed & Fault-Tolerant Systems Programming incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en 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.cookieShort 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.5Cookies 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@hostThe 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@hostSecurity 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.cookiefile - Use TLS distribution for encryption
- Firewall epmd and distribution ports
Preguntas frecuentes
¿La lección «Seguridad de la distribución y cookies» es gratis?
Sí — el texto completo de «Seguridad de la distribución y cookies» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Erlang OTP: Distributed & Fault-Tolerant Systems Programming, actualiza a CoddyKit PRO. El curso de Erlang OTP: Distributed & Fault-Tolerant Systems Programming incluye 4 lecciones en total.
¿Qué aprenderé en «Seguridad de la distribución y cookies»?
Proteja la comunicación entre nodos distribuidos de Erlang mediante magic cookies, nombres de nodo y distribución TLS. Practicas Erlang OTP: Distributed & Fault-Tolerant Systems Programming con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Erlang OTP: Distributed & Fault-Tolerant Systems Programming?
No se requiere experiencia previa. Erlang OTP: Distributed & Fault-Tolerant Systems Programming en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 4 de 4.
¿Cuánto tiempo toma la lección «Seguridad de la distribución y cookies»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Erlang OTP: Distributed & Fault-Tolerant Systems Programming?
Sí. Cada lección de Erlang OTP: Distributed & Fault-Tolerant Systems Programming incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Configuración y comunicación entre nodos
- Llamadas a procedimientos remotos (RPC)
- Registro global de procesos
- Seguridad de la distribución y cookies