在/ usr / bin / w输出中设置“FROM”字段

我想将/ usr / bin / w中的FROM字段设置为不同于我的sshd对用户来自哪里的意见的不同string。 这主要是因为入站ssh通常通过在主中继(例如端口80 HTTP代理或基于浏览器的ssh网关),所以在这种情况下,w列会给localhost。 使用tor注释列出入站tor连接也不错。

有没有办法做到这一点? (例如在PAM的某个地方?)

我检查了一些文档和代码,显然没有办法做到这一点。 FROM utmp字段由sshd设置,该字段使用反向DNS查找来查找在那里使用的内容,而sshd没有关于如何操作的选项。 看一下sshd-u选项来阅读一些关于它的信息(并查看在DNS查找不正确或不存在的情况下失败的情况):

  -u len This option is used to specify the size of the field in the utmp structure that holds the remote host name. If the resolved host name is longer than len, the dotted decimal value will be used instead. This allows hosts with very long host names that overflow this field to still be uniquely identified. Specifying -u0 indicates that only dotted decimal addresses should be put into the utmp file. -u0 may also be used to prevent sshd from making DNS requests unless the authentication mech‐ anism or configuration requires it. Authentication mechanisms that may require DNS include RhostsRSAAuthentication, HostbasedAuthentication, and using a from="pattern-list" option in a key file. Con‐ figuration options that require DNS include using a USER@HOST pattern in AllowUsers or DenyUsers.