大网数据广告活动
服务器运维问答

How can I restrict SSH access to a hostname rather than an IP address without additional software? [debian-server]

· 52CE 我爱测

I am currently in the process of setting up and hardening a small VPS running Debian 11. I have already followed this guide , which involves some basic security measures. However, I would additionally like to limit SSH access to …

问题原文

原帖链接 · Collin · CC BY-SA 4.0

I am currently in the process of setting up and hardening a small VPS running Debian 11. I have already followed this guide, which involves some basic security measures. However, I would additionally like to limit SSH access to my home IP address and perhaps also 1 or 2 more. The issue is that my home IP is liable to change at any time.

Rather than IP addresses, I would like to whitelist one or more hostnames for SSH access. This would allow me to simply update one of my domain's DNS records whenever my home IP changes to restore my access to the VPS.

How can I do this within Debian itself without installing additional packages? Thank you so much.

-Collin

已采纳解答

原帖链接 · asktyagi · CC BY-SA 4.0

Try hosts.deny and hosts.allow file. You can use both ip wild card and as well as dns name wild cards.

#FILE: /etc/hosts.deny(it will deny requests from 192.168.1.* and *.abc.com for ssh)
sshd : 192.168.1. , .abc.com

#FILE: /etc/hosts.allow(it will allow requests from 192.16.1.* and *.myabc.com for ssh)
sshd : 192.16.1. , .myabc.com

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-08-29)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。