Display prompt message after Linux login

Reprinting
Linux can set the welcome message before and after login. Although there is no technical content, it is a very practical trick. To achieve the function of the login message, three files can be modified.

1. /etc/issue Information displayed by local login, before local login

2. The information displayed by /etc/issue.net network login, displayed after login, needs to be configured by sshd

3. /etc/motd is often used for notification information, such as warning of planned shutdown time, etc., prompt information after login

Let's first look at the contents of /etc/issue, as shown in the following figure:
write picture description here

So what do the \r and \m mean, you can use man pam_issue to find out:

Copy code
\d //The date of the local time;
\l //Display the name of the current tty, that is, which tty;
\m //Display the hardware architecture (i386/i486/i586/i686…);
\n / /Display the network name of the host;
\o //Display the domain name;
\r //The version of the current system (equivalent to uname -r)
\t //Display the time of the local time;
\u //Currently there are several User is online.
\s //The name of the current system;
\v //The version of the current system.
Copy code
As for the file /etc/motd, (motd is the abbreviation of motd, which is the abbreviation of message of today bulletin board information), every time the user logs in, the content of the motd file will be displayed on the user's terminal.

The system administrator can edit the system activity messages in the file, for example, the administrator informs the user when the system is to be upgraded for software or hardware, when to perform system maintenance, etc. If the shell supports Chinese,

Chinese can also be used, which seems easier to understand. The disadvantage of /etc/motd is that many users choose to automatically enter the graphical interface when they log in to the system, so this information is often invisible.

The main difference between issue and motd file is that when a user logs in through a local text device (such as a local terminal, local virtual console, etc.)

The file contents of /etc/issue are displayed before the login prompt, while the contents of /etc/motd are displayed after the user has successfully logged into the system.

issue.net file (only for network users) – if logging in through a remote text device (such as through ssh or telnet, etc.), the content of this file will be displayed.

When using ssh to log in, whether the issue information will be displayed is determined by the Banner attribute configuration of the sshd_config of the sshd service, but I found out during testing.

Although the Banner property is set, the \r and \m in issue.net are not escaped, but are displayed directly.

The above three files, issue.net and motd files are displayed after login, so what is the order? I have done a test, as shown in the following figure:

write picture description here

Here the author uses Putty to log in. We can find that the content in the issue.net file is displayed first, and then the content in the motd file is displayed last.

The author also uses Xshell to log in, and the result is the same, that is, the content of the issue.net file is displayed first, and then the content of the motd file is displayed last. In the middle is the last login information.

The differences are:

When using Putty to log in, when we enter the user name root, the content of issue.net is displayed, and after entering the password, the content of motd is displayed.

When using Xshell to log in, only after we enter the user name and password, and the authentication is successful, the contents of the issue.net and motd files will be displayed in turn.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325529944&siteId=291194637