Help us understand the problem. What is going on with this article?

IftttでSSHログインの成功時にLineを飛ばす

概要

SSHログインが成功すると、Lineに通知が行くようにした。

前準備

  • iftttで ifがWebHookなるものをつくっておく

https://ifttt.com/maker_webhooks からDocumentationでcurlのコマンドを出力させておく。
image.png

作業

vi /etc/ssh/sshrc
sshrc
curl -X POST -H "Content-Type: application/json" -d @- '{"value1":}' https://maker.ifttt.com/trigger/イベント/with/key/トークン << EOS
{"value1":"[SSHログイン] ユーザー名: $USER, IP: $SSH_CLIENT"}
EOS
echo ""

これでおk

結果

SSHでは、ログイン時にCongrats!が出ます。

Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-74-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

 System information disabled due to load higher than 8.0


 * Canonical Livepatch is available for installation.
   - Reduce system reboots and improve kernel security. Activate at:
     https://ubuntu.com/livepatch

0 packages can be updated.
0 updates are security updates.


Last login: Sat Jan 25 15:50:56 2020 from 
Congratulations! You've fired the イベント event
mirmdock@mirm_dockernode:~$ 

image.png

参考

https://qiita.com/tekitoh/items/8acccb313d6e7a14c2ec
https://bacchi.me/linux/ssh-login-alert/

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした