使用ssh连接后,如何修改登录提示信息

阿里云Ubuntu登录信息示例

Connecting to 000.000.000.000:22
Connection established
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-81-generic x86_64)
 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

Welcome to Alibaba Cloud Elastic Compute Service !
Last login: Fri Jun 23 13:49:31 2017 from 121.69.23.252

如何自定义展示信息呢?

  1. 数据来源/var/run/motd.dynamic
    该目录中存放的是自系统启动以来描述系统信息的文件,标准要求这个文件夹中的文件必须是在系统启动的时候清空,以便建立新的文件。
    这就导致了,一个问题,当我修改完成后,再次启动时,修改信息依然无效。

  2. 修改方式
    Ubuntu 与别的 Linux 不同,直接修改 /etc/motd 文件重登录后无效。因为这里 /etc/motd 是一个符号链接,指向 /var/run/motd,应该是一个启动后在生成的文件。
    在Ubuntu系统中,找到生成的脚本在目录 /etc/update-motd.d/ 中,那几个有序号的文件就是,包括 00-header,10-help-text , 91-release- upgrade。修改这几个文件,可以得到自己想要的结果。

  3. 笔者修改demo

# 10-help-text
#!/bin/sh
#
#    10-help-text - print the help text associated with the distro
#    Copyright (C) 2009-2010 Canonical Ltd.
#
#    Authors: Dustin Kirkland ,
#             Brian Murray 
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License along
#    with this program; if not, write to the Free Software Foundation, Inc.,
#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
printf "\n"
printf " * Documentation:  https://help.ubuntu.com\n"
printf " * Management:     https://landscape.canonical.com\n"
printf " * Support:        https://ubuntu.com/advantage\n"
printf "\n"
printf " * 大家好,我是自定义信息:\n"

即时展示

修改后用:sudo run-parts /etc/update-motd.d 去执行就会立即见到效果,而不用反复注销登录。

你可能感兴趣的:(使用ssh连接后,如何修改登录提示信息)