在我的hosts.allow的末尾,我有以下内容:
ALL : ALL \
: spawn (echo "%d" | /usr/bin/mail -s "tcpf\: %d attempt from %h." root) & \
: severity auth.info \
: twist /bin/echo "You are not welcome to use %d from %h."`但这似乎只是简单地将该文本放入我的auth.log中:
mail sshd[63546]: twist 12.34.56.789 to /bin/echo "You are not welcome to use sshd from 12.34.56.789."
在客户端,我只看到“远程主机关闭的连接”,没有看到回显的输出。man -k twist里什么都没有
发布于 2017-08-15 11:12:46
hosts_options(5)的手册页解释了tcp_wrappers中的twist命令:
twist shell_command在执行hosts_access(5)手册页中描述的%展开之后,用指定的shell命令实例替换当前进程。Stdin、stdout和stderr连接到客户端进程。此选项必须出现在规则的末尾。
问题是SSH不仅仅是一个文本协议,它还需要一些协议消息,如果它没有接收到它们,它就会失败。如果要在调试模式( ssh )中运行ssh -v,您将看到以下内容:
debug1: Local version string SSH-2.0-OpenSSH_7.5
debug1: ssh_exchange_identification: You are not welcome to use sshd from ::1.
ssh_exchange_identification: read: Connection reset by peer所以消息确实是发送的,但是由于它不是正确的SSH横幅,所以它失败了。没有简单的方法可以将消息注入ssh协议。您可能需要接受这种行为。
https://serverfault.com/questions/868544
复制相似问题