url - 将 SSH 连接限制为特定 URL/域名

标签 url ssh dns

我有一个有 2 个域名的服务器(假设domain1.com 和domain2.com)。 我可以通过 SSH 连接到服务器 ssh <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="99eceafcebd9fdf6f4f8f0f7a8b7faf6f4" rel="noreferrer noopener nofollow">[email protected]</a>ssh <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="295c5a4c5b694d46444840471b074a4644" rel="noreferrer noopener nofollow">[email protected]</a> 。我希望能够只允许 ssh <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="205553455260444f4d41494e110e434f4d" rel="noreferrer noopener nofollow">[email protected]</a>并禁用对domain2.com的SSH访问。

这可能吗?

最佳答案

似乎不可能仅允许 SSH 连接到特定域名。域名由 DNS 解析,SSH 服务器无法知道您正在使用哪个域。另请参阅this回答同一个问题。

您可能尝试做的一件事是配置防火墙(例如 iptable )以删除端口 22 上与 domain2.com 的连接。

讨论了类似的问题here ,他们试图阻止 iptables 中的域,以便访问者无法使用它访问 http 服务器。

根据您的情况调整 iptables 规则(并假设您的 ssh 服务器在端口 22 上运行)我会尝试以下操作:

iptables -I INPUT -p tcp --dport 22 -m string --string "Host: domain2.com" --algo bm -j DROP

更新:

正如 Dusan Bajic 评论的那样,上述规则仅适用于 http 流量,因为它利用 http header fields 。这不适用于 ssh 流量。

关于url - 将 SSH 连接限制为特定 URL/域名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45051621/

相关文章:

python - Flask 多个 URL 处理程序部分处理 URL

http - 设计合适的 REST URI

linux - ssh 连接到另一台服务器上的用户并以该用户身份执行 shell 命令

Java JSch 在远程机器上更改用户并执行命令

PHP查询一条SRV记录

C 通过主机名获取ip

excel - 在 Microsoft EXCEL 中将 URL 格式的内容转换为纯文本

ios - 防止 initWithContentsOfURL : from using cache

git - 无法推送到远程 repo - "Please make sure you have the correct access rights and the repository exists."

windows - 为什么 Windows 不读取我的主机文件?