CentOS7服务器SSH登陆时自动显示服务器基础信息
首先看一下效果
Last login: Mon Jan 16 10:54:30 2023 from 172.16.X.X You are logged in to localhost.localdomain ServerIP:172.16.X.X . System information as of 2023-01-16 11:19:15 [System Info] SYSTEM : CentOS Linux release 7.9.2009 (Core) KERNEL : Linux 3.10.0-1160.el7.x86_64 UPTIME : 1 days 1 hours 20 minutes 0 seconds CPU : Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz (6 vCPU) MEMORY : 6725 MB / 7802 MB (86.18% Used) LOAD AVG : 0.10 (1m), 0.05 (5m), 0.05 (15m) PROCESSES : 145 (root), 9 (user), 154 (total) USERS : 1 users logged in [Disk Usage] Mounted: / 4.8G / 30G (17% Used) [============================================================] Mounted: /boot 145M / 509M (29% Used) [============================================================] Mounted: /data 36M / 30G (1% Used) [============================================================] [root@localhost ~]#
(图片点击放大查看)
例如
dd if=/dev/zero of=/boot/test.iso count=1 bs=340MB
(图片点击放大查看)
将/boot分区临时占满
这时再登陆看到/boot分区已经变为红色
(图片点击放大查看)
具体步骤如下
1、rz上传如下4个文件文件,执行如下命令
[root@localhost home]# mv ./login-banner.sh /etc/profile.d/ [root@localhost home]# chmod +x /etc/profile.d/login-banner.sh [root@localhost home]# mkdir -p /etc/banner [root@localhost home]# mv ./00-login-header /etc/banner/ [root@localhost home]# mv ./10-login-system-info /etc/banner/ [root@localhost home]# mv ./20-login-disk-usage /etc/banner/ [root@localhost home]# chmod +x /etc/banner/*
2、退出SSH,然后再次登陆即可
(图片点击放大查看)
(图片点击放大查看)
(图片点击放大查看)
说明:脚本来源于github,已在原基础上做了相应的修改
获取相应脚本文件