2009年3月30日星期一

ejabberd 2.0.4 Installation and Operation Guide Chapter 5 Securing ejabberd 安全化ejabberd

secure --v 使安全 --金山词霸
5.1 Firewall Settings 防火墙设置

You need to take the following TCP ports in mind when configuring your firewall:
你需要在配置你的防火墙的时候注意一下tcp端口:

Port Description
5222 Standard port for Jabber/XMPP client connections, plain or STARTTLS.
Jabber/XMPP客户连接的标准接口,明文或 STARTTLS(现在还不知道什么意思)
5223 Standard port for Jabber client connections using the old SSL method.
使用老式的SSL方式连接的Jabber客户端连接的标准端口
5269 Standard port for Jabber/XMPP server connections.
Jabber/XMPP服务器连接的标准端口-(是不是就是s2s的port?)
4369 Port used by EPMD for communication between Erlang nodes.
Erlang节点之间使用(EPMD)连接的端口,在cluster中用到了,
port range Used for connections between Erlang nodes. This range is configurable.
端口范文 在Erlang节点之间连接的端口范围,这个范围是可配置的
5.2 epmd

epmd (Erlang Port Mapper Daemon) is a small name server included in Erlang/OTP and used by Erlang programs when establishing distributed Erlang communications. ejabberd needs epmd to use ejabberdctl and also when clustering ejabberd nodes. This small program is automatically started by Erlang, and is never stopped. If ejabberd is stopped, and there aren't any other Erlang programs running in the system, you can safely stop epmd if you want.
epmd是一个小型的在Erlang/OTP中包含的名字服务器(就是dnsserver),目的为建立分布式的Erlang程序提供Erlang通讯。
ejabberd中的ejabberctl(主要的配置程序,脚本)用到,当然cluster模式的ejabberd nodes,也用到了。
这个小程序是被Erlang自动启动的,并且不会停下来(管杀不管埋?)
如果ejabberd已经停了,并且运行环境中没有其他的erlang programs运行,你可以放心的停了它(epmd)
--看样子,epmd是otp环境的功能,没事别管它,是不是可以这样理解?

ejabberd runs inside an Erlang node. To communicate with ejabberd, the script ejabberdctl starts a new Erlang node and connects to the Erlang node that holds ejabberd. In order for this communication to work, epmd must be running and listening for name requests in the port 4369. You should block the port 4369 in the firewall, so only the programs in your machine can access it.

ejabberd在一个Erlang node内部运行。
为了与ejabberd通讯, ejabberctl 脚本启动一个新的Erlang 节点并且连接到包含ejabberd的Erlang节点( the Erlang node that holds ejabberd)
为了让这次通讯运行起来(work), epmd必须跑起来并且在端口4369上监听“名字请求(name requests)"。
这里要注意了,你不能将4369端口放出到公网,这个port仅供你的程序所在的机器之间访问它。




If you build a cluster of several ejabberd instances, each ejabberd instance is called an ejabberd node. Those ejabberd nodes use a special Erlang communication method to build the cluster, and EPMD is again needed listening in the port 4369. So, if you plan to build a cluster of ejabberd nodes you must open the port 4369 for the machines involved in the cluster. Remember to block the port so Internet doesn't have access to it.

如果你建立了一个含几个节点的ejabberd实例, 每个ejabberd实例会被ejabber节点调用。
这些ejabberd 节点使用一种特别的Erlang 通讯方法建立cluster, EPMD被用来监听4369.(这里用了个again,莫非强调EPMD的作用很重要哦!)。
果然,如果你计划建立一个ejabbered 节点的cluster, 你必须在cluster中的机器之间开放4369端口。
记得,别将这个端口开放给internet。(应该是安全的要求)

Once an Erlang node solved the node name of another Erlang node using EPMD and port 4369, the nodes communicate directly. The ports used in this case are random. You can limit the range of ports when starting Erlang with a command-line parameter, for example:
一旦Erlang节点完成了对另一个节点名字的解析,当然是通过EPMD还有4369, 那么节点间就可以直接通讯了。
(应该是讲,完成名字解析后,节点之间通讯时)在这种情况下端口的使用是随机的。你可以在开始Erlang时(命令行参数)限制端口的(活动)范围,例如:

erl ... -kernel inet_dist_listen_min 4370 inet_dist_listen_max 4375
--最小 4370, 最大 4375
5.3 Erlang Cookie

The Erlang cookie is a string with numbers and letters. An Erlang node reads the cookie at startup from the command-line parameter -setcookie. If not indicated, the cookie is read from the cookie file $HOME/.erlang.cookie. If this file does not exist, it is created immediately with a random cookie. Two Erlang nodes communicate only if they have the same cookie. Setting a cookie on the Erlang node allows you to structure your Erlang network and define which nodes are allowed to connect to which.
Erlang cookie是一个包含数字和字母的字串.
Erlang节点根据启动时在命令行参数 -setcookie的设定来读取cookie
如果没有提示的话,cookie将从$HOME/.erlang.cookie的cookie文件中读取。
当这个文件不存在,他会立即创建一个随机的cookie.
两个erlang节点只有在他们cookie相同的条件下才能进行通讯。
通过设定Erlang节点上的cookie可以让你建造你的Erlang网络,定义那些节点可以互联互通。

Thanks to Erlang cookies, you can prevent access to the Erlang node by mistake, for example when there are several Erlang nodes running different programs in the same machine.
应该感谢Erlang cookies, 你可以阻止犯错误的Erlang节点的访问, 例如: 当几个节点运行不同的程序(应用、功能)在相同的一部机器


Setting a secret cookie is a simple method to difficult unauthorized access to your Erlang node. However, the cookie system is not ultimately effective to prevent unauthorized access or intrusion to an Erlang node. The communication between Erlang nodes are not encrypted, so the cookie could be read sniffing the traffic on the network. The recommended way to secure the Erlang node is to block the port 4369.
设定一个保密的cookie是限制非授权访问你的Erlang节点的一个简单办法。
可是,cookie系统并不是阻止非授权访问或入侵一个Erlang节点的有效办法。
Erlang节点之间的通讯没有加密,所以这个cookie可以通过sniffing网路得到。
所以建议还是通过屏蔽4369到(公网),来保证Eralng node.

5.4 Erlang Node Name

An Erlang node may have a node name. The name can be short (if indicated with the command-line parameter -sname) or long (if indicated with the parameter -name). Starting an Erlang node with -sname limits the communication between Erlang nodes to the LAN.
一个Erlang节点有一个节点名字。
这个名字可短可长(如果用-sname来指定那就是短, 如果是-name 那就是长的)
在局域网中,一开始使用-sname来限制通讯

Using the option -sname instead of -name is a simple method to difficult unauthorized access to your Erlang node. However, it is not ultimately effective to prevent access to the Erlang node, because it may be possible to fake the fact that you are on another network using a modified version of Erlang epmd. The recommended way to secure the Erlang node is to block the port 4369.
使用-sname替换-name是一个简单的方法用来限制非授权访问。
但是它不是最终有效的阻止Erlang 节点的访问, 因为它可以伪装一个实际中的另一个节点,使用修改过的Erlang epmd.
所以建议还是通过屏蔽4369到(公网),来保证Eralng 节点.

5.5 Securing Sensible Files

ejabberd stores sensible data in the file system either in plain text or binary files. The file system permissions should be set to only allow the proper user to read, write and execute those files and directories.
ejabberd存储敏感数据在一个文件系统中明文或二进制格式。
文件系统授权只允许恰当的用户读,写,执行相应的文件或目录

ejabberd configuration file: /etc/ejabberd/ejabberd.cfg
ejabberd的配置文件: /etc/ejabberd/ejabberd.cfg
Contains the JID of administrators and passwords of external components. The backup files probably contain also this information, so it is preferable to secure the whole /etc/ejabberd/ directory.
包含管理员JID, 密码, 外部模块.
最好备份整个/etc/ejabberd目录
ejabberd service log: /var/log/ejabberd/ejabberd.log
ejabberd服务的日志: /var/log/ejabberd/ejabberd.log
Contains IP addresses of clients. If the loglevel is set to 5, it contains whole conversations and passwords. If a logrotate system is used, there may be several log files with similar information, so it is preferable to secure the whole /var/log/ejabberd/ directory.
包含用户的ip地址.
如果log记录级别为5, 它包含整个会话和密码. 如果logrotate使用, 会有几个类似日志文件含有类似的信息,最好保证整个/var/log/ejabberd目录的安全

Mnesia database spool files: /var/lib/ejabberd/db/*
Mnesia数据库spool files: /var/lib/ejabberd/db/*
The files store binary data, but some parts are still readable. The files are generated by Mnesia and their permissions cannot be set directly, so it is preferable to secure the whole /var/lib/ejabberd/db/ directory.
Erlang cookie file: /var/lib/ejabberd/.erlang.cookie
See section 5.3.
这些文件是以二进制存储的,但是其中有些部分是可读的。这些文件是Mnesia创建的并且他们的许可(permission)不能直接授权访问,最好保证这个目录的安全/var/lib/ejabbered/db/
Erlang cookie 文件:/var/lib/ejabberd/.erlang.cookie

没有评论:

发表评论