0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2020-01-25

概要

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

前準備

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

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

作業

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

これでおk。
ただし、ここでどんな些細なことでも標準出力があると、sftpが使えなくなるので注意。

結果

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 
mirmdock@mirm_dockernode:~$ 

image.png

参考

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

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?