Restrict logon locations of users in Linux

Source: Internet
Author: User
Restrict the logon location of users in Linux-general Linux technology-Linux programming and kernel information. The following is a detailed description. When a user logs on, after verifying passwd, the system first executes a file in/etc according to shell. sh, ksh is profile, csh is csh. cshrc, bash is bashrc. at this time, the user login location is verified to prevent some possible intruder. the following is a program I used on the Siemens RM600 parallel machine/etc/profile.

....

....

# Check for authenication

If [-r/etc/checkfrom. awk]; then

VALID = 'finger | awk-f/etc/checkfrom. awk'

If ["$ VALID "! = "WELCOME"]; then

Echo "Intruder, get away from here !!! "

Exit

Fi

Fi

.....

......


/Etc/checkfrom. awk is an awk program with the following content:


BEGIN {site ["aft01"] = 1;

Site ["aft02"] = 1;

Site ["aft03"] = 1;

Site ["aft04"] = 1;

Site ["aft05"] = 1;

Site ["rs6000"] = 1;

}

$1 = ENVIRON ["LOGNAME"] {

If ($ NF !~ /[0-9] +: [0-9] + /){

I = NF-3

If ("/dev/" $ I = ENVIRON ["TTY"]) {

If (ENVIRON ["TTY"]! = "/Dev/console "){

If ($ NF in site) print "WELCOME"

Else print "GETAWAY"

}

Else print "WELCOME"

Exit 0

}

}

Else {

I = NF-2

If ("/dev/" $ I = ENVIRON ["TTY"]) {

Print "WELCOME"

Exit 0

}

}

}


Note: note the format displayed by finger on your machine. The format on my machine is as follows:

$ Finger

Lsad % finger

Login Name TTY Idle When Where

Tiger Wang Shuhu console Mon

Lsad %

The above awk program is written in this format for your reference only.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.