Linux 下如何修改 ssh 登录欢迎信息

效果预览

操作步骤

  1. 新建一个sh脚本文件

    vim motd.sh
  2. 在文件中添加如下内容(可根据需要自行修改 echo 部分的内容)

    #!/bin/bash
    #define the filename to use as output
    motd="/etc/motd"
    # Collect useful information about your system
    # $USER is automatically defined
    HOSTNAME=`uname -n`
    KERNEL=`uname -r`
    CPU=`uname -p`
    ARCH=`uname -m`
    # The different colours as variables
    W="\033[01;37m"
    B="\033[01;34m"
    R="\033[01;31m"
    X="\033[00;37m"
    G="\033[01;32m"
    # clear > $motd # to clear the screen when showing up
    echo -e "                                                         " >> $motd
    echo -e "        Welcome to $B Your-Host-Name $X server.          " >> $motd
    echo -e "                                                         " >> $motd
    echo -e "  $G The world is not you can do, but you should.      $X " >> $motd
    echo -e "$B" >> $motd
    echo -e "         \   ,__,                                        " >> $motd
    echo -e "          \  (oo)____                                    " >> $motd
    echo -e "             (__)    )\                                  " >> $motd
    echo -e "                ||--|| *                                 " >> $motd
    echo -e "$X" >> $motd
  3. 以root用户执行该脚本

    $ ./motd.sh 
    或 
    $ sh motd.sh