UNIX系统中限制终端登录

数码时尚

  在UNIX系统中,可以轻松实现只对部分终端开放,限制用户从其他终端登录,以保证进入系统的合法性的功能。

  笔者将以下的SHELL脚本加入到/etc/profie文件中,就实现了上述功能:

  If test `tty`="/dev/tty??"

  then if test $LOGNAME="Username"

  then echo "Welcome to Unix system!!"

  else echo "Sorry,You are not to permmitted to login"

  exit

  fi

  else echo "The system is not open to this TERM"

  exit

  fi

  其中“/dev/tty??”为登录终端名,“Username”为合法用户名。