{"id":296,"date":"2021-01-03T01:28:16","date_gmt":"2021-01-03T00:28:16","guid":{"rendered":"https:\/\/www.duoweb.de\/?p=296"},"modified":"2021-04-06T19:14:38","modified_gmt":"2021-04-06T17:14:38","slug":"e-mail-beim-ssh-login","status":"publish","type":"post","link":"https:\/\/www.duoweb.de\/index.php\/2021\/01\/03\/e-mail-beim-ssh-login\/","title":{"rendered":"E-Mail beim SSH Login"},"content":{"rendered":"<p>Eine Datei anlegen, die beim erfolgreichen Login ausgef\u00fchrt wird.<img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-400 alignright\" src=\"https:\/\/www.duoweb.de\/wp-content\/uploads\/2021\/01\/SSH-2.png\" alt=\"\" width=\"160\" height=\"93\"><\/p>\n<p>Bspw. login_info.sh anlegen<\/p>\n<p><code>nano \/etc\/ssh\/<strong>login_info.sh<\/strong><\/code><\/p>\n<p>und f\u00fcr eine Mail folgenden Inhalt einf\u00fcgen:<\/p>\n<pre>#!\/bin\/sh\r\nif [ \"$PAM_TYPE\" != \"open_session\" ]\r\nthen\r\nexit 0\r\nelse\r\n{\r\necho \"User: $PAM_USER\"\r\necho \"Remote Host: $PAM_RHOST\"\r\necho \"Service: $PAM_SERVICE\"\r\necho \"TTY: $PAM_TTY\"\r\necho \"Date: `date`\"\r\necho \"Server: `uname -a`\"\r\n} | mail -s \"$PAM_SERVICE login on `hostname` for account $PAM_USER\" <em>&lt;mail@domain.tld&gt;<\/em>\r\nfi\r\nexit 0<\/pre>\n<p>Nun mit CHMOD Erlaubnis zur Ausf\u00fchrung setzen. (+x)<br \/>\nUnd nun das Script am Ende der Datei <code>\/etc\/pam.d\/sshd<\/code> eintragen:<br \/>\n<code>session optional pam_exec.so seteuid \/etc\/ssh\/<strong>login_info.sh<\/strong><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Eine Datei anlegen, die beim erfolgreichen Login ausgef\u00fchrt wird. Bspw. login_info.sh anlegen nano \/etc\/ssh\/login_info.sh und f\u00fcr eine Mail folgenden Inhalt einf\u00fcgen: #!\/bin\/sh if [ &#8222;$PAM_TYPE&#8220; != &#8222;open_session&#8220; ] then exit 0 else { echo &#8222;User: $PAM_USER&#8220; echo &#8222;Remote Host: $PAM_RHOST&#8220; echo &#8222;Service: $PAM_SERVICE&#8220; echo &#8222;TTY: $PAM_TTY&#8220; echo &#8222;Date: `date`&#8220; echo &#8222;Server: `uname -a`&#8220; } |<\/p>\n<p class=\"more-link\"><a href=\"https:\/\/www.duoweb.de\/index.php\/2021\/01\/03\/e-mail-beim-ssh-login\/\" class=\"themebutton2\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[11,9],"tags":[],"class_list":["post-296","post","type-post","status-publish","format-standard","hentry","category-linux","category-raspberry"],"_links":{"self":[{"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/posts\/296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/comments?post=296"}],"version-history":[{"count":9,"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/posts\/296\/revisions"}],"predecessor-version":[{"id":401,"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/posts\/296\/revisions\/401"}],"wp:attachment":[{"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/media?parent=296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/categories?post=296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.duoweb.de\/index.php\/wp-json\/wp\/v2\/tags?post=296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}