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

Sicurezza della distribuzione e cookie

Protegga la comunicazione tra nodi Erlang distribuiti usando magic cookie, denominazione dei nodi e distribuzione TLS.

Lezione 4 di 413 passaggi

Sicurezza della distribuzione e cookie è una lezione Erlang OTP: Distributed & Fault-Tolerant Systems Programming gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Erlang OTP: Distributed & Fault-Tolerant Systems Programming, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Erlang OTP: Distributed & Fault-Tolerant Systems Programming include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

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
Gratis per iniziare

Impara Erlang con un tutor IA — gratis

Scrivi ed esegui vero codice nel tuo browser, ricevi aiuto istantaneo da un tutor IA disponibile 24/7, e riprendi da dove hai lasciato sul web o nell'app.

Corsi
12
Lezioni
48

Domande Frequenti

La lezione «Sicurezza della distribuzione e cookie» è gratuita?

Sì — il testo completo di «Sicurezza della distribuzione e cookie» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Erlang OTP: Distributed & Fault-Tolerant Systems Programming, passa a CoddyKit PRO. Il corso Erlang OTP: Distributed & Fault-Tolerant Systems Programming include 4 lezioni in totale.

Cosa imparerò in «Sicurezza della distribuzione e cookie»?

Protegga la comunicazione tra nodi Erlang distribuiti usando magic cookie, denominazione dei nodi e distribuzione TLS. Eserciti Erlang OTP: Distributed & Fault-Tolerant Systems Programming con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Erlang OTP: Distributed & Fault-Tolerant Systems Programming?

Non è richiesta alcuna esperienza precedente. Erlang OTP: Distributed & Fault-Tolerant Systems Programming su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.

Quanto tempo richiede la lezione «Sicurezza della distribuzione e cookie»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Erlang OTP: Distributed & Fault-Tolerant Systems Programming?

Sì. Ogni lezione Erlang OTP: Distributed & Fault-Tolerant Systems Programming include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Configurazione e comunicazione tra nodi
  2. Chiamate di procedura remota (RPC)
  3. Registrazione globale dei processi
  4. Sicurezza della distribuzione e cookie
← Torna a Erlang OTP: Distributed & Fault-Tolerant Systems Programming