Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In /etc/securetty I commented out tty2 and tty3:

#tty2
#tty3

This succesfully disables root login for these two terminals for root.

But is it possible to display a message such as "root login is disabled in this terminal" if a login attempt is made?

share|improve this question
add comment

1 Answer 1

You can get the current terminal with the tty command, so you can put something like this in the user's .bash_profile file:

if [ `tty` = "/dev/pts/0" ]
then
   echo "......."
fi
share|improve this answer
    
I think this file won't run at all since the login failed. –  arsane Aug 30 '12 at 8:55
    
Then you can allow the login, and run that script with an "exit" at the end, but I don't know if it's completely safe –  golimar Aug 30 '12 at 9:34
    
@arsane you are right its not working. but thanks for the hint golimar –  max Sep 3 '12 at 10:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.