- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Restriction so that only root can login at con...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 07:05 AM
06-06-2003 07:05 AM
untrusted(vendor requirement)
I have a security requirement to not allow any
user except root to login via the console. Of
course the other non root users will need to login
via telnet, remsh, ftp, etc.
Is this possible?
Thanks (and points) for any and all input.
Paul
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 07:39 AM
06-06-2003 07:39 AM
Re: Restriction so that only root can login at console.
I believe it can be done, but you'll have to write a custom pam module for login. This pam module would allow only root to login if the tty is console returning PAM_PERM_DENIED otherwise. If the tty is not console, then simply return PAM_SUCCESS.
Insert this new module in your /etc/pam.conf
login auth requisite /usr/lib/security/pam_YourCustomModule.so.1
just above
login auth required /usr/lib/security/libpam_unix.1
pam link:
http://www.cs.rit.edu/~hpb/Man/_Man_Solaris_2.6_html/html3/pam.3.html
Tyler
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 07:42 AM
06-06-2003 07:42 AM
Re: Restriction so that only root can login at console.
just a couple of hints:
- write in /etc/securetty the word "console"
this way root is only allowed to login at console.
- Then, put in the .profile of each user a scirpt that do and exit if the terminal is a console. You can check this with the command "tty"
HTH,
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 07:43 AM
06-06-2003 07:43 AM
Re: Restriction so that only root can login at console.
/etc/securetty
console
HTH,
Piyush
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 07:46 AM
06-06-2003 07:46 AM
Re: Restriction so that only root can login at console.
For added security, the owner of that file should be root:bin and permission should be 600.
HTH,
Piyush
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 07:47 AM
06-06-2003 07:47 AM
Re: Restriction so that only root can login at console.
If you were to trust the system you can use devassign to stop others from using the console. See man 4 devassign for more info.
regards,
Darren.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 08:04 AM
06-06-2003 08:04 AM
Re: Restriction so that only root can login at console.
/etc/securetty is to allow root to login *only* from console. It does not mean others cannot login from the console. However, you will still need to use this file to avoid root logins through network.
You can put a small check in your /etc/profile (for sh/ksh as an example) to see if the user is not root AND the "tty' is /dev/console. If so, then exit otherwise let the user login.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 08:11 AM
06-06-2003 08:11 AM
Re: Restriction so that only root can login at console.
if
tty = console
then
echo ???not allowed to login to console???
exit
else
continue()
if
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 08:21 AM
06-06-2003 08:21 AM
Re: Restriction so that only root can login at console.
if [[ $(/usr/bin/tty) = "/dev/console" && $(whoami) != "root" ]]
then
echo not allowed to login to console
exit
fi
Usual warnings apply: test carefully, remove the "exit" until you're happy with the script.
regards,
Darren.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 08:34 AM
06-06-2003 08:34 AM
Re: Restriction so that only root can login at console.
but still no joy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 09:05 AM
06-06-2003 09:05 AM
Re: Restriction so that only root can login at console.
Use /etc/securetty! It's approved, supported, and most of all proven to work.
Regards,
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 09:13 AM
06-06-2003 09:13 AM
Re: Restriction so that only root can login at console.
I cut and pasted Darren's suggestion into my /etc/profile and tested it. It worked like a charm.
What shell are you using? What console (i.e. serial, or gui)?
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 09:23 AM
06-06-2003 09:23 AM
Re: Restriction so that only root can login at console.
the console is GUI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 09:28 AM
06-06-2003 09:28 AM
Re: Restriction so that only root can login at console.
Darren's script should work.
Also Shannon made a good point. You will also need to modify /etc/dt/config/Xstartup script to add these checks. You will need to check if the DISPLAY has been set to the host appearing in "who -mR" output. Since you may not even want root to login through CDE logins, it is better you completely disable CDE.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 09:34 AM
06-06-2003 09:34 AM
Re: Restriction so that only root can login at console.
I am logging in through CDE
would like to keep CDE if possible
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 09:34 AM
06-06-2003 09:34 AM
Re: Restriction so that only root can login at console.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 09:43 AM
06-06-2003 09:43 AM
Re: Restriction so that only root can login at console.
I don't see how whoami would be used
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 09:44 AM
06-06-2003 09:44 AM
Re: Restriction so that only root can login at console.
If the user wants CDE as their desk, more power to them. But, that means that much of what we could do to secure server with no graphics console is out the window.
There is not an easy fix for this, which is why I said use /etc/securetty. It checks the login only, so your good. Im sure in a day of playing around, you could get something to work half as? in /etc/profile, but why go through all the trouble?
Regards,
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 09:48 AM
06-06-2003 09:48 AM
Re: Restriction so that only root can login at console.
I'm not absolutely sure this would work and I'm not willing to log out at the moment to do any testing, but, if you'll just execute the command "who am i |awk '{ print $2 }'", you'll see that it returns a tty number. If you'll do a "who" command, you'll see that the initial login shows "console" whereas all the other processes show a tty. My theory is that putting a test in /etc/profile, which would be invoked during the initial login, would return "console", and you could then check user for "root" and exit, just as Darren showed.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 11:30 AM
06-06-2003 11:30 AM
Re: Restriction so that only root can login at console.
I put in my profile
if [[ $(who am i | awk '{print $2}') = "/dev/console" && $(whoami) != "root" ]]
then
echo not allowed to login to console
exit
fi
but it still let me login
any other thoughts?
BTW thanks for all the input so far
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 12:01 PM
06-06-2003 12:01 PM
Re: Restriction so that only root can login at console.
If I understand your requirements correctly, then you are using CDE and you do not want others to login through your workstation. If that is the case edit /etc/dt/config/Xstartup file and put the following.
HOST=$(echo $DISPLAY|awk '{FS=":";print $1}'|awk '{FS=".";print $1}')
MYHOST="Your_host" #Your_host is the hostname on which you do not want the non-root users to login
if [[ $HOST = $MYHOST && $USER != "root" ]]
then
exit 1
fi
If you don't have a Xstartup file, copy it from /usr/dt/config directory.
The above script will allow other users to login from CDE sessions on boxes other than your_host.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 12:32 PM
06-06-2003 12:32 PM
Re: Restriction so that only root can login at console.
I don't know if it works but try this:
TTYCHECK=`/usr/bin/tty | cut ???d \/ -f4`
If [[ ???$TTYCHECK??? = ???console??? && $(whoami) != "root" ]]
then
echo "not allowed to login to console"
sleep 5
exit
fi
Regards,
DR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 12:40 PM
06-06-2003 12:40 PM
Re: Restriction so that only root can login at console.
the command:
echo $DISPLAY|awk '{FS=":";print $1}'|awk '{FS=".";print $1}'
returns 164
which is the first octect of the servers ip address?
so
$HOST = $MYHOST will never be tru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 12:47 PM
06-06-2003 12:47 PM
SolutionI was able to try the following and it worked:
TTYCHECK=`/usr/bin/tty | cut -d \/ -f4`
if [[ "$TTYCHECK" != "console" && $(whoami) = "root" ]]
then
echo $TTYCHECK
fi
Just try my previous reply it should work for you.
Regards,
DR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 12:57 PM
06-06-2003 12:57 PM
Re: Restriction so that only root can login at console.
It works perfectly from the console/server but when I remsh from a different workstation to the server I get
Usage: cut -b List [-n] [File...]
or: cut -c List [File...]
or: cut -f List [-d Character] [-s] [File...]
${HOME:-.}/.profile[36]: If: not found
${HOME:-.}/.profile[36]: syntax error: `then' unexpected
I don't fully understand your code any ideas. I want to bunnie this issue