如何在linux上定制telnetlogin提示符

当我在debian上运行login命令时,我得到:

 hostname login: _ 

在RHEL5,Solaris或HP-UX上,我得到:

 login: _ 

我需要能够自定义login:password:在Linux机器上提示它。 我可以重新编译这个包,但有没有更好的(更简单)的方法来做到这一点?

我正在寻找一些PAMconfiguration选项,但没有find任何东西。

我知道这可以通过使用PAM_USER_PROMPT常量的pam_set_item()函数来PAM_USER_PROMPT ,但有没有办法在/etc/pam.d/*configuration文件中进行这种定制?

先谢谢你。

更新:

我需要这个来定制telnet用户名和密码提示。 但是, telnetd使用/bin/login作为提示,这就是为什么我要求在这个问题login自定义。

您可以尝试将系统区域设置更改为包含所需标签的自定义区域设置。

如果使用mingetty则可以在/etc/inittab指定--nohostname参数

 1:2345:respawn:/sbin/mingetty --nohostname tty1 1:2345:respawn:/sbin/mingetty --nohostname tty2 --nohostname Do not print the hostname before the login prompt. 

如果在/ etc / inittab中使用mgetty,则可以附加-p标志来更改login提示

 man mgetty -p <login prompt> Use the given string to prompt users for their login names. Various tokens are allowed in this string. These tokens are: @ for the system name, \n, \g, \f, for new- line, bell, and form feed, respectively. \v and \r will expand to the OS version and release. \P, \l and \L will expand to the tty name ("ttyS0"). \Y will give the Caller ID, \I the "CONNECT foobar" string returned by the modem, and \S or \b will output the port speed. \N and \U give the number of users currently logged in. \C will be changed into the result of ctime(), and \D or \d and \t or \T will output the date and time, respectively. Finally, \<digit> will use digit as octal/deci- mal/hexadecimal representation of the character to follow. The default prompt is specified at compile time. 

它发现telnetd接受-L /path/to/login选项,所以我写了几行python代码来提供我自己的/bin/login选项,使用PAM进行身份validation并login -f来打开loginshell。

在那个python脚本中,我可以定义任何提示我需要login:password:

根据telnetd手册页,使用默认选项要求凭据,而不是login

它也有这个选项:

  -h Disables the printing of host-specific information before login has been completed. 

大概你用这个选项调用telnetd – 如果你删除它,它会给你想要的行为?

理论上,要更改Password:提示符,可以在/etc/login.defs定义一个LOGIN_STRING ,如下所示:

 LOGIN_STRING "%s, Please enter your password: " 

%s将被用户名replace)

但事实上,这个选项似乎已经过时,并且不再工作:

 configuration error - unknown item 'LOGIN_STRING' (notify administrator) 

它也在/etc/login.defs提到:

 # XXX - it doesn't work correctly yet, for now leave it commented out # to use the default which is just "Password: ". 

关于login:提示符,您可以通过设置PAM_USER_PROMPT或重新编译login-utils软件包来更改它:

 /* * [email protected]: Provide a user prompt to PAM * so that the "login: " prompt gets localized. Unfortunately, * PAM doesn't have an interface to specify the "Password: " string * (yet). */ retcode = pam_set_item(pamh, PAM_USER_PROMPT, _("login: ")); PAM_FAIL_CHECK;