Snippets

Łukasz Wójcik Debian: email me every time someone logs in via SSH

Updated by aaa aaa

File ssh-login-notify.markdown Modified

  • Ignore whitespace
  • Hide word diff
+* Install mailx:
+
+```
+$ sudo aptitude install mailutils
+```
+
 * Add in `/etc/pam.d/sshd:`
 
 ```
Updated by aaa aaa

File snippet.markdown Deleted

  • Ignore whitespace
  • Hide word diff
-* Add in `/etc/pam.d/sshd:`
-
-```
-session optional pam_exec.so seteuid /etc/ssh/login-notify.sh
-```
-
-* Add the file:
-
-```
-$ sudo touch /etc/ssh/login-notify.sh
-$ chmod +x /etc/ssh/login-notify.sh
-```
-
-* Edit the content:
-
-```bash
-#!/bin/sh
-
-# Change these two lines:
-sender="ssh@server.com"
-recepient="root@anotherserver.com"
-
-if [ "$PAM_TYPE" != "close_session" ]; then
-        host="`hostname`"
-        subject="SSH Login: $PAM_USER from $PAM_RHOST on $host"
-        message="`env`"
-        echo "$message" | mailx -r "$sender" -s "$subject" "$recepient"
-fi
-```
-
-* Done

File ssh-login-notify.markdown Added

  • Ignore whitespace
  • Hide word diff
+* Add in `/etc/pam.d/sshd:`
+
+```
+session optional pam_exec.so seteuid /etc/ssh/login-notify.sh
+```
+
+* Add the file:
+
+```
+$ sudo touch /etc/ssh/login-notify.sh
+$ chmod +x /etc/ssh/login-notify.sh
+```
+
+* Edit the content:
+
+```bash
+#!/bin/sh
+
+# Change these two lines:
+sender="ssh@server.com"
+recepient="root@anotherserver.com"
+
+if [ "$PAM_TYPE" != "close_session" ]; then
+        host="`hostname`"
+        subject="SSH Login: $PAM_USER from $PAM_RHOST on $host"
+        message="`env`"
+        echo "$message" | mailx -r "$sender" -s "$subject" "$recepient"
+fi
+```
+
+* Done
Updated by aaa aaa

File snippet.markdown Modified

  • Ignore whitespace
  • Hide word diff
-1. Add in `/etc/pam.d/sshd:`
+* Add in `/etc/pam.d/sshd:`
 
 ```
 session optional pam_exec.so seteuid /etc/ssh/login-notify.sh
 ```
 
-2. Add the file:
+* Add the file:
 
 ```
 $ sudo touch /etc/ssh/login-notify.sh
 $ chmod +x /etc/ssh/login-notify.sh
 ```
 
-3. Edit the content:
+* Edit the content:
 
-```
+```bash
 #!/bin/sh
 
 # Change these two lines:
 fi
 ```
 
-4. Done
+* Done
Created by aaa aaa

File snippet.markdown Added

  • Ignore whitespace
  • Hide word diff
+1. Add in `/etc/pam.d/sshd:`
+
+```
+session optional pam_exec.so seteuid /etc/ssh/login-notify.sh
+```
+
+2. Add the file:
+
+```
+$ sudo touch /etc/ssh/login-notify.sh
+$ chmod +x /etc/ssh/login-notify.sh
+```
+
+3. Edit the content:
+
+```
+#!/bin/sh
+
+# Change these two lines:
+sender="ssh@server.com"
+recepient="root@anotherserver.com"
+
+if [ "$PAM_TYPE" != "close_session" ]; then
+        host="`hostname`"
+        subject="SSH Login: $PAM_USER from $PAM_RHOST on $host"
+        message="`env`"
+        echo "$message" | mailx -r "$sender" -s "$subject" "$recepient"
+fi
+```
+
+4. Done
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.