{"id":483,"date":"2021-06-08T03:07:35","date_gmt":"2021-06-07T17:07:35","guid":{"rendered":"https:\/\/ghiassy.net\/?p=483"},"modified":"2021-06-08T03:08:07","modified_gmt":"2021-06-07T17:08:07","slug":"email-successful-ssh-login","status":"publish","type":"post","link":"https:\/\/ghiassy.net\/?p=483","title":{"rendered":"Email successful SSH Login"},"content":{"rendered":"<p><span style=\"color: #00ff00;\">In case if you want to send an warning email to user or admin once the user successfully logged in through SSH, the script below can be added to &#8220;\/etc\/profile&#8221;.<\/span><\/p>\n<p><span style=\"color: #00ff00;\">This file is loaded on users login.<\/span><\/p>\n<p><span style=\"color: #00ff00;\"><!--more--><\/span><\/p>\n<pre class=\"lang:sh decode:true \" title=\"Send email with SSH login\">#Added by SaEeD\r\n#Send an email if SSH login was successful\r\nif [ -n \"$SSH_CLIENT\" ]; then\r\n    TEXT=\"$(date): ssh login to ${USER}@$(hostname -f)\"\r\n    TEXT=\"$TEXT from $(echo $SSH_CLIENT|awk '{print $1}')\"\r\n    echo $TEXT|mail -s \"WARNING!!! - successful SSH Login\" saeed@hexor.ir\r\nfi<\/pre>\n<p><span style=\"color: #00ff00;\">Hope this helps, good luck \ud83d\ude42<\/span><\/p>\n<p><span style=\"color: #00ff00;\">&#8212; Saeed<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In case if you want to send an warning email to user or admin once the user successfully logged in through SSH, the script below can be added to &#8220;\/etc\/profile&#8221;. This file is loaded on users login.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,6],"tags":[],"class_list":["post-483","post","type-post","status-publish","format-standard","hentry","category-linux","category-servers"],"_links":{"self":[{"href":"https:\/\/ghiassy.net\/index.php?rest_route=\/wp\/v2\/posts\/483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ghiassy.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ghiassy.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ghiassy.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ghiassy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=483"}],"version-history":[{"count":5,"href":"https:\/\/ghiassy.net\/index.php?rest_route=\/wp\/v2\/posts\/483\/revisions"}],"predecessor-version":[{"id":517,"href":"https:\/\/ghiassy.net\/index.php?rest_route=\/wp\/v2\/posts\/483\/revisions\/517"}],"wp:attachment":[{"href":"https:\/\/ghiassy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ghiassy.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ghiassy.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}