限制服务访问
/etc/hosts.allow,添加允许访问的IP(如192.168.1.0/24: telnetd)。/etc/hosts.deny,设置ALL: telnetd禁止其他IP访问。sudo ufw allow from <可信IP> to any port 23。禁用高风险功能
/etc/pam.d/login,注释pam_securetty.so行。/etc/passwd,将用户shell设为/sbin/nologin。sudo apt install openssh-server。sudo systemctl stop inetd && sudo systemctl disable inetd。/etc/ssh/sshd_config): PermitRootLogin no:禁止root登录。PasswordAuthentication no:启用密钥认证。AllowUsers <用户名>:限制登录用户。sudo systemctl start ssh && sudo systemctl enable ssh。/var/log/auth.log,监控异常登录行为。注意:Telnet协议本身不加密,存在数据泄露风险,建议仅在测试环境使用,生产环境务必使用SSH。
参考来源: