<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Technical Diary &#187; pam</title>
	<atom:link href="http://andriigrytsenko.net/tag/pam/feed/" rel="self" type="application/rss+xml" />
	<link>http://andriigrytsenko.net</link>
	<description>With Andrii Grytsenko</description>
	<lastBuildDate>Tue, 17 Aug 2010 08:25:33 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Login restriction by time over pam.d</title>
		<link>http://andriigrytsenko.net/2009/08/login-restriction-by-time-over-pam-d/</link>
		<comments>http://andriigrytsenko.net/2009/08/login-restriction-by-time-over-pam-d/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 15:53:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[pam]]></category>
		<category><![CDATA[redhat]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=423</guid>
		<description><![CDATA[If you I want to allow users log in in to system only at working hours use pam_time.so module. This example works on CentOS and I suspect that it will be work at RHEL as well.

We should edit to files for this:
/etc/pam.d/login
/etc/security/time.conf
Let&#8217;s begin from first one. Put next line into the file:
account    [...]]]></description>
			<content:encoded><![CDATA[<p>If you I want to allow users log in in to system only at working hours use pam_time.so module. This example works on CentOS and I suspect that it will be work at RHEL as well.</p>
<p><span id="more-423"></span></p>
<p>We should edit to files for this:<br />
<em>/etc/pam.d/login<br />
/etc/security/time.conf</em></p>
<p>Let&#8217;s begin from first one. Put next line into the file:</p>
<pre>account    required     pam_time.so</pre>
<p>after that go to the <em>/etc/security/time.conf</em>, and insert next:</p>
<pre>login;tty*;user1|user2|user3;Wk0009-1800 &amp; !Wd0000-2400</pre>
<p>where<br />
<em>login</em> &#8211; the type of pam service<br />
<em>tty*</em> &#8211; terminal name(in this case all terminal ttyXXX, you also specify defined terminal as well)<br />
<em>user1|user2|user3</em> &#8211; users or user name which should be restricted<br />
<em>Wk0009-1800 &amp; !Wd0000-2400</em> &#8211; time frame. Time where actions is allowed. To inverse it put &#8220;!&#8221; before.  There is 7 types of day:<br />
<em>Mo Tu We Th Fr Sa Su Wk Wd Al</em><br />
First seven is according to weeks day.<br />
<em>Wk</em> &#8211; means all work days(Mo-Fr)<br />
<em>Wd</em> &#8211; it&#8217;s week end(Sa,SU)<br />
<em>Al</em> &#8211; all days of week.</p>
<p>Now, you new rules was applied. And users user1, user2, user3 can&#8217;t log on system at no working time. No restart is required.</p>
<p>But we still have one problem. Users which logined at work time can be continuous use system without problem. To prevent this situation I have written little <a href="http://andriigrytsenko.net/files/time.txt">script</a>.</p>
<p>Rename it to <em>time.sh</em> and put anywhere at your system. After this new crontab entry should be added:</p>
<pre>crontab -e</pre>
<pre>55 17 * * 1-5    /path/to/time.sh</pre>
<p>Now all session will be destroyed at the end of working day and script notify user via user&#8217;s terminal 5 minutes before this. After that nobody from specified users willn&#8217;t be able to login on the system.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/08/login-restriction-by-time-over-pam-d/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
