أمان التوزيع وملفات Cookies
أمّن الاتصال بين عُقد Erlang الموزعة باستخدام ملفات magic cookies وتسميات العُقد وتوزيع TLS.
أمان التوزيع وملفات Cookies درس مجاني في Erlang OTP: Distributed & Fault-Tolerant Systems Programming على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Erlang OTP: Distributed & Fault-Tolerant Systems Programming، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Erlang OTP: Distributed & Fault-Tolerant Systems Programming 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
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
تعلم Erlang مع معلم ذكاء اصطناعي — مجانًا
اكتب وقم بتشغيل أكوادك الفعلية في المتصفح، واحصل على مساعدة فورية من معلم ذكاء اصطناعي متاح 24/7، واستمر من حيث توقفت على الويب أو في التطبيق.
- الدورات
- 12
- الدروس
- 48
الأسئلة الشائعة
هل درس «أمان التوزيع وملفات Cookies» مجاني؟
نعم — نص درس «أمان التوزيع وملفات Cookies» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Erlang OTP: Distributed & Fault-Tolerant Systems Programming، انتقل إلى CoddyKit PRO. تتضمن دورة Erlang OTP: Distributed & Fault-Tolerant Systems Programming 4 دروس في المجموع.
ماذا ستتعلم في «أمان التوزيع وملفات Cookies»؟
أمّن الاتصال بين عُقد Erlang الموزعة باستخدام ملفات magic cookies وتسميات العُقد وتوزيع TLS. تتمرن على Erlang OTP: Distributed & Fault-Tolerant Systems Programming مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Erlang OTP: Distributed & Fault-Tolerant Systems Programming؟
لا تُشترط خبرة سابقة. Erlang OTP: Distributed & Fault-Tolerant Systems Programming على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «أمان التوزيع وملفات Cookies»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Erlang OTP: Distributed & Fault-Tolerant Systems Programming هذا؟
نعم. كل درس في Erlang OTP: Distributed & Fault-Tolerant Systems Programming يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- إعداد العقد والتواصل بينها
- استدعاءات الإجراءات البعيدة (RPC)
- تسجيل العمليات عالميًا
- أمان التوزيع وملفات Cookies