<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="mn">
		<id>https://wiki.dusal.net/index.php?action=history&amp;feed=atom&amp;title=SSH_%D1%85%D0%BE%D0%BB%D0%B1%D0%BE%D0%BB%D1%82_%D1%85%D0%B8%D0%B9%D0%B3%D0%B4%D1%8D%D1%85%D1%8D%D0%B4_%D0%BC%D1%8D%D0%B9%D0%BB%D1%8D%D1%8D%D1%80_%D0%BC%D1%8D%D0%B4%D1%8D%D0%B3%D0%B4%D1%8D%D1%85</id>
		<title>SSH холболт хийгдэхэд мэйлээр мэдэгдэх - Түүх</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.dusal.net/index.php?action=history&amp;feed=atom&amp;title=SSH_%D1%85%D0%BE%D0%BB%D0%B1%D0%BE%D0%BB%D1%82_%D1%85%D0%B8%D0%B9%D0%B3%D0%B4%D1%8D%D1%85%D1%8D%D0%B4_%D0%BC%D1%8D%D0%B9%D0%BB%D1%8D%D1%8D%D1%80_%D0%BC%D1%8D%D0%B4%D1%8D%D0%B3%D0%B4%D1%8D%D1%85"/>
		<link rel="alternate" type="text/html" href="https://wiki.dusal.net/index.php?title=SSH_%D1%85%D0%BE%D0%BB%D0%B1%D0%BE%D0%BB%D1%82_%D1%85%D0%B8%D0%B9%D0%B3%D0%B4%D1%8D%D1%85%D1%8D%D0%B4_%D0%BC%D1%8D%D0%B9%D0%BB%D1%8D%D1%8D%D1%80_%D0%BC%D1%8D%D0%B4%D1%8D%D0%B3%D0%B4%D1%8D%D1%85&amp;action=history"/>
		<updated>2026-05-04T12:24:51Z</updated>
		<subtitle>Вики дэх энэ хуудасны засварын түүх</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https://wiki.dusal.net/index.php?title=SSH_%D1%85%D0%BE%D0%BB%D0%B1%D0%BE%D0%BB%D1%82_%D1%85%D0%B8%D0%B9%D0%B3%D0%B4%D1%8D%D1%85%D1%8D%D0%B4_%D0%BC%D1%8D%D0%B9%D0%BB%D1%8D%D1%8D%D1%80_%D0%BC%D1%8D%D0%B4%D1%8D%D0%B3%D0%B4%D1%8D%D1%85&amp;diff=248&amp;oldid=prev</id>
		<title>Almas: Шинэ хуудас:       Warning: As always when you change the login configuration, leave a backup ssh session open in the background and test the login from a new terminal.  Since the sshrc me…</title>
		<link rel="alternate" type="text/html" href="https://wiki.dusal.net/index.php?title=SSH_%D1%85%D0%BE%D0%BB%D0%B1%D0%BE%D0%BB%D1%82_%D1%85%D0%B8%D0%B9%D0%B3%D0%B4%D1%8D%D1%85%D1%8D%D0%B4_%D0%BC%D1%8D%D0%B9%D0%BB%D1%8D%D1%8D%D1%80_%D0%BC%D1%8D%D0%B4%D1%8D%D0%B3%D0%B4%D1%8D%D1%85&amp;diff=248&amp;oldid=prev"/>
				<updated>2015-08-31T05:28:34Z</updated>
		
		<summary type="html">&lt;p&gt;Шинэ хуудас:       Warning: As always when you change the login configuration, leave a backup ssh session open in the background and test the login from a new terminal.  Since the sshrc me…&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Шинэ хуудас&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
    Warning: As always when you change the login configuration, leave a backup ssh session open in the background and test the login from a new terminal.&lt;br /&gt;
&lt;br /&gt;
Since the sshrc method doesn't work if the user has their own ~/.ssh/rc file, I'll explain how to do this with pam_exec as @adosaiguas suggested. The good thing is that this can also be easily adapted to login types other than ssh (such as local logins or even all logins) by hooking into a different file in /etc/pam.d/.&lt;br /&gt;
&lt;br /&gt;
First you need to be able to send mail from the command line. There are other questions about this. On a mail server it's probably easiest to install mailx (which is probably already installed anyway).&lt;br /&gt;
&lt;br /&gt;
Then you need an executable script file login-notify.sh (I put it in /etc/ssh/ for example) with the following content. You can change the variables to change the subject and content of the e-mail notification. Don't forget to execute chmod +x login-notify.sh to make it executable.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Change these two lines:&lt;br /&gt;
sender=&amp;quot;sender-address@example.com&amp;quot;&lt;br /&gt;
recepient=&amp;quot;notify-address@example.org&amp;quot;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if [ &amp;quot;$PAM_TYPE&amp;quot; != &amp;quot;close_session&amp;quot; ]; then&lt;br /&gt;
    host=&amp;quot;`hostname`&amp;quot;&lt;br /&gt;
    subject=&amp;quot;SSH Login: $PAM_USER from $PAM_RHOST on $host&amp;quot;&lt;br /&gt;
    # Message to send, e.g. the current environment variables.&lt;br /&gt;
    message=&amp;quot;`env`&amp;quot;&lt;br /&gt;
    echo &amp;quot;$message&amp;quot; | mailx -r &amp;quot;$sender&amp;quot; -s &amp;quot;$subject&amp;quot; &amp;quot;$recepient&amp;quot; &amp;amp;&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Once you have that, you can add the following line to /etc/pam.d/sshd:&lt;br /&gt;
&lt;br /&gt;
session optional pam_exec.so seteuid /path/to/login-notify.sh&lt;br /&gt;
&lt;br /&gt;
For testing purposes, the module is included as optional, so that you can still log in if the execution fails. After you made sure that it works, you can change optional to required. Then login won't be possible unless the execution of your hook script is successful (if that is what you want).&lt;br /&gt;
&lt;br /&gt;
For those of you in need of an explanation of what PAM is and how it works, here is a very good one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Ангилал:Linux]][[Ангилал:Сисадмин]]&lt;/div&gt;</summary>
		<author><name>Almas</name></author>	</entry>

	</feed>