<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Direct Login VS. su only in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/direct-login-vs-su-only/m-p/5068516#M94741</link>
    <description>Thanks again.</description>
    <pubDate>Wed, 12 Sep 2007 12:34:37 GMT</pubDate>
    <dc:creator>Bob Ferro</dc:creator>
    <dc:date>2007-09-12T12:34:37Z</dc:date>
    <item>
      <title>Direct Login VS. su only</title>
      <link>https://community.hpe.com/t5/operating-system-linux/direct-login-vs-su-only/m-p/5068511#M94736</link>
      <description>I tried the script to not allow direct login and it worked fine except when I tried to su - myuserid, it didn't let me in either.  Is there a way to distinguish between a direct login and a su in /etc/profile?&lt;BR /&gt;&lt;BR /&gt;Here's the script from another thread:&lt;BR /&gt;&lt;BR /&gt;Since all normal shell logins go through /etc/profile, there are a number of controls you can put into /etc/profile. As mentioned, you can limit root so it is not allowed a direct login except through the console, and indirectly using su (or better yet, sudo). For the rest of the users, you might create a file of disallowed users such as /etc/disallowed.users with each user login on a separate line such as:&lt;BR /&gt;&lt;BR /&gt;billh&lt;BR /&gt;jamesf&lt;BR /&gt;kens&lt;BR /&gt;&lt;BR /&gt;Then near the top of /etc/profile (ALWAYS after the line: trap "" 1 2 3) add something like this:&lt;BR /&gt;&lt;BR /&gt;for NOTALLOWED in $(cat /etc/disallowed)&lt;BR /&gt;do&lt;BR /&gt;if [ $LOGNAME = $NOTALLOWED ]&lt;BR /&gt;then&lt;BR /&gt;echo "\n --- login not allowed ---\"&lt;BR /&gt;exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;And that's it. Now anytime billh, jamesf or kens try to login, they are kicked out immediately.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 12 Sep 2007 08:10:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/direct-login-vs-su-only/m-p/5068511#M94736</guid>
      <dc:creator>Bob Ferro</dc:creator>
      <dc:date>2007-09-12T08:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Direct Login VS. su only</title>
      <link>https://community.hpe.com/t5/operating-system-linux/direct-login-vs-su-only/m-p/5068512#M94737</link>
      <description>Hi Bob:&lt;BR /&gt;&lt;BR /&gt;If you are truly doing 'su - user' and not 'su user' then '/etc/profile' should be sourced.&lt;BR /&gt;&lt;BR /&gt;If you test '$0' (the running process) in 'etc/profile' you will see either '-sh' for a normal login or '-su' if the user issued 'su - user'.  That's one way to distinguish a direct login from an 'su'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 12 Sep 2007 08:22:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/direct-login-vs-su-only/m-p/5068512#M94737</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-09-12T08:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: Direct Login VS. su only</title>
      <link>https://community.hpe.com/t5/operating-system-linux/direct-login-vs-su-only/m-p/5068513#M94738</link>
      <description>&lt;!--!*#--&gt;Hi Bob:&lt;BR /&gt;&lt;BR /&gt;Here's an exaple of the code I suggested in my post, above:&lt;BR /&gt;&lt;BR /&gt;if [ ${0} = "-sh" ]; then&lt;BR /&gt;    if [ ${LOGNAME} = "bob" ]; then&lt;BR /&gt;        echo "...login is direct; you MUST 'su -' to login"&lt;BR /&gt;        sleep 5&lt;BR /&gt;        exit                        &lt;BR /&gt;    fi&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 12 Sep 2007 10:31:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/direct-login-vs-su-only/m-p/5068513#M94738</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-09-12T10:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: Direct Login VS. su only</title>
      <link>https://community.hpe.com/t5/operating-system-linux/direct-login-vs-su-only/m-p/5068514#M94739</link>
      <description>James,&lt;BR /&gt;&lt;BR /&gt;After the trap "" 1 2 3 command in the /etc/profile,  I added the following commands.  Your suggestions worked fine, I just combined them.                           &lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;for NOTALLOWED in $(cat /etc/disallowed.users)&lt;BR /&gt; do&lt;BR /&gt; if [ $LOGNAME = $NOTALLOWED ] &amp;amp;&amp;amp; [ ${0} = "-sh" ]&lt;BR /&gt; then&lt;BR /&gt;   echo "\n Direct logins not allowed for your account."&lt;BR /&gt;   echo "\n You must   su - $NOTALLOWED    from another user."&lt;BR /&gt;   read&lt;BR /&gt; exit&lt;BR /&gt; fi&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Sep 2007 12:32:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/direct-login-vs-su-only/m-p/5068514#M94739</guid>
      <dc:creator>Bob Ferro</dc:creator>
      <dc:date>2007-09-12T12:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: Direct Login VS. su only</title>
      <link>https://community.hpe.com/t5/operating-system-linux/direct-login-vs-su-only/m-p/5068515#M94740</link>
      <description>&lt;!--!*#--&gt;James,&lt;BR /&gt;&lt;BR /&gt;After the trap "" 1 2 3 command in the /etc/profile,  I added the following commands.  Your suggestions worked fine, I just combined them.                           &lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;for NOTALLOWED in $(cat /etc/disallowed.users)&lt;BR /&gt; do&lt;BR /&gt; if [ $LOGNAME = $NOTALLOWED ] &amp;amp;&amp;amp; [ ${0} = "-sh" ]&lt;BR /&gt; then&lt;BR /&gt;   echo "\n Direct logins not allowed for your account."&lt;BR /&gt;   echo "\n You must   su - $NOTALLOWED    from another user."&lt;BR /&gt;   read&lt;BR /&gt; exit&lt;BR /&gt; fi&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Sep 2007 12:33:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/direct-login-vs-su-only/m-p/5068515#M94740</guid>
      <dc:creator>Bob Ferro</dc:creator>
      <dc:date>2007-09-12T12:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: Direct Login VS. su only</title>
      <link>https://community.hpe.com/t5/operating-system-linux/direct-login-vs-su-only/m-p/5068516#M94741</link>
      <description>Thanks again.</description>
      <pubDate>Wed, 12 Sep 2007 12:34:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/direct-login-vs-su-only/m-p/5068516#M94741</guid>
      <dc:creator>Bob Ferro</dc:creator>
      <dc:date>2007-09-12T12:34:37Z</dc:date>
    </item>
  </channel>
</rss>

