Gil*_*il' 75
该UseDNS选项大多无用。如果客户端计算机在 Internet 上,则它们很可能没有任何反向 DNS,它们的反向 DNS 无法正向解析,或者它们的 DNS 不提供“属于此”以外的任何信息IP 地址已经告诉您的 ISP”。
在典型配置中,DNS 仅用于日志记录。它可以用于身份验证,但前提IgnoreRhosts no是在sshd_config. 这是为了与旧设备的兼容性是使用RSH,在那里你可以说“之称的用户bob被称为机上darkstar可登录为alice没有显示任何凭证”(写darkstar bob在~alice/.rhosts)。只有当您信任所有可能连接到 ssh 服务器的机器时,它才是安全的。换句话说,这很少能以安全的方式使用。
鉴于 DNS 查找不提供任何有用的信息,除非在非常特殊的情况下,它应该被关闭。据我所知,它默认开启的唯一原因是它在技术上更安全(如果您关心身份验证,而不是可用性),即使这仅适用于一小部分情况。
关闭此功能的另一个理由是,每个多余的功能都是不必要的安全风险。
小智 45
我在 Ubuntu 中添加了一个关于这个的错误报告(旧的但仍然是最新的)。
https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/424371
我建议将默认值更改为 No 并在其上添加更新的文档:
# UseDNS - Determines whether IP Address to Hostname lookup and comparison is performed
# Default value is No which avoids login delays when the remote client's DNS cannot be resolved
# Value of No implies that the usage of "from=" in authorized_keys will not support DNS host names but only IP addresses.
# Value of Yes supports host names in "from=" for authorized_keys. Additionally if the remote client's IP address does not match the resolved DNS host name (or could not be reverse lookup resolved) then a warning is logged.
Run Code Online (Sandbox Code Playgroud)
从联机帮助页sshd_config(5):
UseDNS Specifies whether sshd(8) should look up the remote host name and
check that the resolved host name for the remote IP address maps
back to the very same IP address. The default is “yes”.
Run Code Online (Sandbox Code Playgroud)
启用此功能后,从没有正确(正向和反向)DNS 的位置进行访问会在日志中生成警告。
所以这并不能阻止任何攻击,只是它需要一些合格的客户端远程地址才能不记录任何警告。只有当 PTR 记录有意义时,这样的警告才能帮助您追踪攻击者。
编辑:根据Andrey Voitenkov 的评论更新。
当您在authorized_keys 文件中使用FROM 选项并且您想按名称过滤而不仅仅是IP 时需要它。
Authorized_keys 文件中一行中的 FROM 选项允许您限制可以使用特定密钥的主机。
这增加了管理可以相互访问的多个服务器的能力,而不允许机器的克隆冒充它的来源,通常是无意的(剩余的 crontabs,人为错误)。