脚本如容如下:

lvse="\033[32m"
zise="\033[35m"
end="\033[0m"
dmidestatus=$(rpm -qa | grep dmidecode | wc -l)
totalmemkb=$(cat /proc/meminfo | grep "MemTotal" | awk '{print $2}')
echo -e "                   "${zise}"System Date:"${end}${lvse}$(date +"%F %T")${end}
echo -e "                   "${zise}"System Name:"${end}${lvse}$([ -f /etc/redhat-release ] && cat /etc/redhat-release || uname -o)${end}
echo -e "                "${zise}"System machine:"${end}${lvse}$(uname -m)${end}
echo -e "                 "${zise}"System uptime:"${end}${lvse}$(uptime)${end}
if [ $dmidestatus -eq 1 ];then echo -e "                "${zise}"System Product:"${end}${lvse}$(dmidecode -s system-product-name) ${end};fi
if [ $dmidestatus -eq 1 ];then echo -e "                 "${zise}"System Serial:"${end}${lvse}$(dmidecode -s system-serial-number) ${end};fi
echo -e "                    "${zise}"Login User:"${end}${lvse}$(whoami)${end}
echo -e "                      "${zise}"Login IP:"${end}${lvse}$(w | grep pts | head -n 1 | awk '{print $3}')${end}
echo -e "                           "${zise}"Cpu:"${end}${lvse}$(cat /proc/cpuinfo | grep "model name" | tail -n 1 | awk -F ":" '{print $2}' | sed '
s/           / /g')
echo -e "                      "${zise}"Cpu Core:"${end}${lvse}$(cat /proc/cpuinfo | grep "model name" | wc -l)${end}
echo -e "                     "${zise}"Cpu Count:"${end}${lvse}$(cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l)${end}
echo -e "                        "${zise}"Memory:"${end}${lvse}$((totalmemkb/1000000))" GB"${end}
echo -e "                     "${zise}"interface:"${end}${lvse} $(ip addr show | grep inet | egrep -v "lo$|:" |  awk '{print $NF,": " $2}')${end}

把如上内容放入/etc/ssh/sshrc 文件  如果没有次文件 就新建,然后退出登录  重新登陆 显示如下:

                   System Date:2017-07-19 14:25:41
                   System Name:CentOS release 6.5 (Final)
                System machine:x86_64
                 System uptime: 14:25:41 up 89 days, 13:35, 2 users, load average: 0.07, 0.04, 0.00
                System Product:PowerEdge R610 
                 System Serial:1111111
                    Login User:root
                      Login IP:2.2.2.2
                           Cpu: Intel(R) Xeon(R) CPU L5630 @ 2.13GHz
                      Cpu Core:16
                     Cpu Count:2
                        Memory:8
                     interface: em1 : 1.1.1.1/27 em2 : 192.168.1.2/24