linux 登录成功后,自动发送消息到钉钉
1、开启钉钉机器人
2、Linux登录时执行
用户登录时,Bash 首先执行全局登录脚本(由 root 建立) /etc/profile,然后在用户起始目录下依次寻找 .bash_profile、.bash_login、.profile 三个文件,执行最先找到的一个。
用户退出登录时还可以运行 .bash_logout 脚本
在/etc/profile.d/里创建一个loginsend.sh来添...
1、开启钉钉机器人
2、Linux登录时执行
用户登录时,Bash 首先执行全局登录脚本(由 root 建立) /etc/profile,然后在用户起始目录下依次寻找 .bash_profile、.bash_login、.profile 三个文件,执行最先找到的一个。
用户退出登录时还可以运行 .bash_logout 脚本
在/etc/profile.d/里创建一个loginsend.sh来添加自己的脚本
----发送钉钉消息脚本----
curl 'https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{"msgtype": "text","text": {"content":"我就是我, 是不一样的烟火"}}'
----发送钉钉消息脚本----
在发送的消息中可以增加登录ip的显示
---------------------------------------------
我在wsl中进行测试过程,
一、安装ssl
1.移除系统本身的ssh
sudo apt remove openssh-server
2.安装
sudo apt -y install openssh-server
3.修改配置文件
sudo vim /etc/ssh/sshd_config
开启端口、地址和允许密码登录
Port 22
ListenAddress 0.0.0.0
PasswordAuthentication yes
4.重启ssh服务
sudo service ssh restart
记一次ssh public key login失败原因
配置:
.ssh/config
host cms
HostName 114.215.*.*
User zhongxinxin
IdentityFile ~/.ssh/id_rsa
登录:
ssh cms
结果:
zhongxinxin@114.215.*.*'s password:
检查原因:
1.客户端检查
ssh -vv cms,未发现异常
2.服务端检查
执行登录的同时,监控安全日志
sudo tail -f less...
配置:
.ssh/config
host cms
HostName 114.215.*.*
User zhongxinxin
IdentityFile ~/.ssh/id_rsa
登录:
ssh cms
结果:
zhongxinxin@114.215.*.*'s password:
检查原因:
1.客户端检查
ssh -vv cms,未发现异常
2.服务端检查
执行登录的同时,监控安全日志
sudo tail -f less /var/log/secure
Authentication refused: bad ownership or modes for directory /home/zhongxinxin
解决问题:
google关键字,找到此文章,原因是当前用户的根目录权限设置不妥。
检查发现当前用户根目录的权限是drwxrwx---,通过权限调整,仅保留当前用户权限,问题解决。
chmod g-wrx /home/zhongxinxin
yuxiang2013@gmail.com