How to customize telnet login prompt on linux
Solution 1
You may try to change system locale to your custom locale containing desired labels.
Solution 2
If you are using mingetty
then you can specify the --nohostname
parameter in /etc/inittab
1:2345:respawn:/sbin/mingetty --nohostname tty1
1:2345:respawn:/sbin/mingetty --nohostname tty2
--nohostname
Do not print the hostname before the login prompt.
Solution 3
It have found that telnetd
accepts -L /path/to/login
option, so I have written few lines of python code to provide my own /bin/login
alternative using PAM to authenticate and login -f
to open a login shell.
In that python script I can define whatever prompt I need for both login:
and password:
.
Solution 4
if you use mgetty in /etc/inittab you can append the -p flag to change the login prompt
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.
Related videos on Youtube
samina
Updated on September 18, 2022Comments
-
samina over 1 year
When I run
login
command on debian, I get:hostname login: _
on RHEL5, Solaris or HP-UX I get:
login: _
I need to be able to customize
login:
andpassword:
prompts it on a Linux box. I can recompile the package, but is there a better (easier) way to do it?I was looking for some PAM config option but didn't find anything.
I know it can be done with the pam_set_item() function using
PAM_USER_PROMPT
constant, but is there a way to do such customization in a/etc/pam.d/*
config file?Thank you in advance.
UPDATE:
I need this to customize telnet username and password prompt. However,
telnetd
is using/bin/login
for that prompt, this is why I asked forlogin
customization in this question.-
samina over 12 yearsI wasn't sure where to ask this question. I was considering also ServerFault, but I expected more PAM experts here.
-
Bernie White over 12 yearsAre you wanting to change for console or ssh connection?
-
samina over 12 years@BernieWhite: SSH is not an option (unfortunately). I need that for telnet server which (as far as I know) is using
login
binary.
-
-
samina over 12 yearsSorry, I cannot use
mgetty
. It's needed for telnetd login prompt customization, and telnet calls/bin/login
. It must work with/bin/login
alone. -
samina over 12 yearsI cannot use
mingetty
. See comment for Mike's answer. -
samina over 12 yearsThanks MikeyB. I need to change the prompt to something completely different. In other words, I need to be able to change prompt for example to: "Hello, what's your user name ?" and "your password please...".
-
samina over 12 yearsYes, I just noted that "login:" and "password:" from
login
is locale aware. This might be best alternative for a recompiling the package. -
samina over 12 yearsIt tuns out that "login: " is taken from
/usr/share/locale-langpack/en/LC_MESSAGES/shadow.mo
, while "Password: " is taken from another/usr/share/locale-langpack/en/LC_MESSAGES/Linux-PAM.mo
file. -
John Chew almost 7 yearsThe -h option MikeyB mentions is used to control the display of /etc/issue.net before the line with the login: prompt, and has no effect on the display of the hostname on that line.