yangli-1128

linux 登录成功后,自动发送消息到钉钉

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

标签: linux login
上一篇 下一篇
评论
©yangli-1128 | Powered by LOFTER