- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- why it doesnt work?
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
02-21-2002 06:25 PM
02-21-2002 06:25 PM
in this passage,it says:
For Bourne and POSIX shells, add the following to /etc/profile:
#unsupported statements to prevent users from login but allow su.
name=`logname`
if [ $name = username ]
then
echo $name not allowed to login...only su
exit
fi
#end
however i add it to my /etc/profile,but it doesnt work,what's wrong?
following is :
name=`logname`
if [ $name = pin2 ]
then
echo " $name not allowed to login..only su"
exit
fi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 06:32 PM
02-21-2002 06:32 PM
Re: why it doesnt work?
Ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 06:36 PM
02-21-2002 06:36 PM
Re: why it doesnt work?
Replace logname with id -un and add the double quotes on $name to be sure.
name=`id -un`
if [ "$name" = "pin2" ]
then
echo " $name not allowed to login..only su"
exit
fi
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 06:42 PM
02-21-2002 06:42 PM
Re: why it doesnt work?
if [ "$name" = "pin2" ]
Hope this helps.
Kenny.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 07:04 PM
02-21-2002 07:04 PM
Re: why it doesnt work?
name=`id -un`
if [ "$name" = "pin2" ]
then
echo " $name not allowed to login..only su"
exit
fi
but it still doesnt work ,i still could use pin2 to login
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 07:11 PM
02-21-2002 07:11 PM
Re: why it doesnt work?
Tested to work fine for me.
Insert this statement in your /etc/profile right before the loop starts:
echo The login user is `id -un`
What does it show when pin2 logs in?
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 07:15 PM
02-21-2002 07:15 PM
Re: why it doesnt work?
In other words:
echo The login user is `id -un`
name=`id -un`
if [ "$name" = "pin2" ]
then
echo " $name not allowed to login..only su"
exit
fi
When you test pin2, you will see the printed output:
The login user is ...
What is printed there?
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 07:27 PM
02-21-2002 07:27 PM
Re: why it doesnt work?
maybe i didnt understand this script correctly
following is my understanding:
unix server:A,B
i add that script to B'/etc/profile,so it means that when i telnet B from A ,and when i
input pin2 in login,it will not allow me to input passwd.
isnt it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 07:32 PM
02-21-2002 07:32 PM
Re: why it doesnt work?
Hope this helps.
Kenny.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 07:32 PM
02-21-2002 07:32 PM
Re: why it doesnt work?
/etc/profile will be called only after successful login. Which means that you will ahve to enter your login name & password.
Then, if your login name if "pin2", you will be thrown out immediately.
You are specifying "pin2" at the login: prompt, right?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 07:35 PM
02-21-2002 07:35 PM
Re: why it doesnt work?
When you telnet from system A to system B, system B will still prompt you for the password before "kicking" you out from system B.
/etc/profile is read upon successful login.
If you do not want the login prompt to be even shown, then you should use /var/adm/inetd.sec (on system B) to restrict the IP addresses (ie. system A fixed IP) that can telnet to system B
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 07:36 PM
02-21-2002 07:36 PM
Re: why it doesnt work?
Hope this helps.
Kenny.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 07:39 PM
02-21-2002 07:39 PM
Re: why it doesnt work?
Just an additional note that by restricting telnet via IP addresses in /var/adm/inetd.sec, you will block all userids from system A, in addition to pin2.
I would say that it is still safe to allow the user to be prompted for password and then get kicked out from /etc/profile.
If you don't like this, the workaround is to create a trust relationship either using SSH (ie. authorized_keys)or .rhosts (insecure) so that the user will not be prompted for login from system A and still get kicked out from /etc/profile (which has traps within which the user cannot break out ie. ctrl-c).
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 07:46 PM
02-21-2002 07:46 PM
Re: why it doesnt work?
Hope this helps.
Kenny.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 07:50 PM
02-21-2002 07:50 PM
Re: why it doesnt work?
I agree with Kenny's method. I think changing the passwd field in /etc/passwd is the cleaniest solution to your requirements.
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 08:18 PM
02-21-2002 08:18 PM
Re: why it doesnt work?
i tested a shell x:name=`id -un`
if [ "$name" = "pin2" ]
then
echo " $name not allowed to login..only su"
exit
fi
when i use pin2 to test x,it show
pin2 not allwed to login..only su
but pin2 doesnt exit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 08:32 PM
02-21-2002 08:32 PM
Re: why it doesnt work?
Hope this helps.
Kenny.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 08:49 PM
02-21-2002 08:49 PM
Re: why it doesnt work?
when i use root to login:
it show:The login user is root
but when i use pin2 to login
it dosent show the message.
another thing i wanna know,when i login with pin2,system call which profile?
/etc/profile or /home/pin2/.profile?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 08:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 09:03 PM
02-21-2002 09:03 PM
Re: why it doesnt work?
root is sbin/sh
i didnt notice it.
now ,what should i do
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 09:13 PM
02-21-2002 09:13 PM
Re: why it doesnt work?
set name=`id -un`
if ( "$name" == "pin2" ) then
echo "$name not allowed to login..only su"
exit
endif
and when i use pin2 to login ,it show pin2 not allowed to login..only su
however it doesnt exit system,do i need add parameter to exit?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 09:16 PM
02-21-2002 09:16 PM
Re: why it doesnt work?
Replace "exit" with "logout".
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2002 09:41 PM
02-21-2002 09:41 PM
Re: why it doesnt work?
thank everyone here,you are so helpful
i make two mistakes in this question:
1.i didnt notice user's shell
2.should replace exit with logout
thank u all again