,,,
TOC o "1-3" ............................................................................................. PAGEREF _Toc74760928 h
1. PAGEREF _Toc74760929 h
2. Linux................. PAGEREF _Toc74760930 h
2.1. .............................................................. PAGEREF _Toc74760931 h
2.2. Linux...................................... PAGEREF _Toc74760932 h
2.2.1. ...................................................................... PAGEREF _Toc74760933 h
2.2.2. ................................................................. PAGEREF _Toc74760934 h
2.2.3. ..................................................................... PAGEREF _Toc74760935 h
2.3. PAM......................................................................... PAGEREF _Toc74760936 h
2.4. ................................................................................. PAGEREF _Toc74760937 h
2.5. ................................................................ PAGEREF _Toc74760938 h
3. Linux................. PAGEREF _Toc74760939 h
3.1. Linux ACLs.................................................................................. PAGEREF _Toc74760940 h
3.2. LIDS............................................................................................. PAGEREF _Toc74760941 h
3.3. AIDE............................................................................................ PAGEREF _Toc74760942 h
4. ......................................................... PAGEREF _Toc74760943 h
..................................................................................... PAGEREF _Toc74760944 h
..................................................................... PAGEREF _Toc74760945 h
..................................................................................... PAGEREF _Toc74760946 h
, UNIX- , . , , , . , , , , , . , . , , .
, , Linux , , , . , Linux. Linux - , , .
: ; ; , UNIX , Linux , .
. , . , , . , , . : , , .
, . , , .
, . , , , .
, , ! , ( . cracker ), , . . . . - , , , .
- . , , . Linux UNIX- , .
, . : , .
, (, , ), , (, ).
, . .
:
1.
, . , . , , , . , , , , , , ( , ). .
, . , . , , , . , , . , .
2.
, . , , (, ), , , (), . . , , , .
, .
:
, , . , , . "" "" "".
( ) , . , , - .
, . , , , , . , .
.
, , , , , .
Linux , . , , Linux, , , . , . , .
, , , , . , Linux . , . , .
, , , .
Linux . Linux 2.1.
Linux , , , , , .
?
, , .
- ( , , ). , . ? - , .
- , ( root). , . .
- , , (, , ). , , , .
. , , , . , .
, Linux .
, , . , , .
Linux , . . , root .
Linux passwd. etc, , , /. .
passwd.
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
7 :
1. . . , , , , , , .
2. . Linux , , , x. .
3. (UID). Linux , . , , . .
4. , (GID). .
5. . , , .
6. . Linux , . /home .
7. . ( bash). , . /sbin/nologin. bin . nologin , . , /sbin/nologin, . , , - . , , , /sbin/nologin. /bin/false. , Linux, , . , , . , . false , , , , .
, , passwd. root, ( Linux).
, , , . : useradd, usermod userdel.
useradd . . , s shell, g , . /etc/passwd, useradd , /home. d, .
usermod , , , , .
, userdel. . man-.
, . . . , .
, , , .
Linux .
( ), .
. Linux. . , , .
/etc/shadow. Linux /etc/passwd. , . , shadow .
.
root:$1$pOy8fNrf$uOh/dQlI03BMIdEAhWrE.0:12369:0:99999:7:::
bin:*:12245:0:99999:7:::
daemon:*:12245:0:99999:7:::
sync:*:12245:0:99999:7:::
shadow, passwd, :
1. . passwd.
2. . Linux , . . DES (Data Encryption Standard). .
.
( Linux). , , .
Linux passwd. . , , . 2 . /etc/shadow.
mingetty. mingetty , . - . login. login -, , . . login , shell ( . shell ). shell passwd. bash (Bourne Shell). # $ ( # , $ - ). .
Linux . , - .
, 4 passwd. , . Linux.
1.
.
, Ѡ .
, . , .
Linux ext2 (The Second Extended File System). Ext2 , , ext2 Linux, .
ext2: 4 ; 2 ; 255 ; ; ; .
, . , , , , , . , , . permission denied ( ). B , . , , , , .
Linux , 3 : , , , - , , . , , , , , .
, , , . 3- . , . 1 , 0 .
.
. , .
. - .
. .
, , ls l:
[root@app tmpdir]# ls l
lrwxrwxrwx 1 root users 86 7 19:49 linkfile -> myfile
drwxr-xr-x 1 root users 4096 7 19:49 lnk
-rwxr----- 1 anotheruser users 97 7 19:48 myfile1
-rw-rw-r-- 1 root users 84 7 19:45 myfile2
. 10 . , , , , . , , . . , -, , , - .
, linkfile myfile. l . , . , , , . lnk , d . , root, - users. , . r ( Read) , w ( Write) , x ( eXecute) . , users, ( r x), . , -. myfile1 myfile2 . myfile2 ( root) users, . myfile1 , , anotheruser. users , - .
chmod. , . man-.
. Sticky bit, SUID SGID.
Sticky bit (S). . Sticky bit , , , , .
SUID (s). SUID , , , . , , . , , passwd, , root, SUID, shadow, root.
SGID (s). SGID, SUID, , . SGID , , , .
[root@app mydir]# ls l
-rwsr--r-x 1 anotheruser users 97 7 19:48 myfile1
, myfile1 SUID. ( ) , anotheruser.
. , . , SUID , . , root. , .
2.
, , , , , . , , . , , , .
1.1, Linux . 2.4 :
Atime (A). , , . atime , , . , , .
Sync (S). sync , , , . , - .
Append (a). . . , , , , .
Immutable (i). immutable . , , , . .
No Dump (d). no dump , , .
Compress (c). . .
Secure Deletion (s). , , , , , .
Undelete (u). , .
, 2.4, : compress, secure deletion undelete. , .
Linux chattr lsattr. , , . lsattr .
[root@app tmpdir]# lsattr myfile*
---i---------- myfile
----a--------- myfile1
immutable, atime. lsattr chattr man-.
, , . , ext2 , sys_open() sys_truncate() , , . , immutable , , , . Linux , . , . , - .
, , immutable append, . , , root . , , root, .
, , 2.4, immutable append . lcap (Linux Kernel Capabilities Bounding Set Editor).
lcap
[root@app /]# lcap CAP_LINUX_IMMUTABLE
[root@app /]# lcap CAP_SYS_RAWIO
lcap CAP_LINUX_IMMUTABLE immutable append. CAP_SYS_RAWIO , , .
, lcap - , . , .
lcap man-.
3.
, . , , .
, / , .
: , , , , , . , , , . , .
: (soft limit), (hard limit) (grace period).
, .
, grace period.
, , , , , . , . . .
. Linux , , . , . Quota Support (CONFIG_QUOTA) FileSystems . , , . - . .
. /etc/fstab, , . usrquota grpquota.
quota. Linux , .
quota 3.11. quota-3.11, :
quota . , . .
convertquota quota.user quota.group aquota.user aquota.group. quota.user quota.group . 2.4.0, Linux , , , :
- 32- (UID);
- ;
- ( );
- ReiserFS.
aquota.user aquota.group. , convertquota , .
edquota . , . .
qout . quot, 3.11, XFS.
quotacheck . , . quotacheck , , . - , .
quotaon . usrquota / grpquota /etc/fstab.
quotaoff .
repquota .
setquota .
warnquota , . .
quota man-.
4.
PAM (Pluggable Authentication Modules) . PAM , , . , . . , PAM. , , PAM, , , PAM. PAM , , . PAM PAM. PAM.
. 2.3.1 PAM
2.3.1 , PAM. PAM, , . , , PAM. Linux-PAM ( ) . ( ) ( auth, b ). Linux-PAM . , , .
PAM /lib/security, PAM /etc/pam.d. , /etc/pam.d, , . , login PAM /etc/pam.d/login. :
#%PAM-1.0
auth required /lib/security/pam_securetty.so
auth required /lib/security/pam_stack.so service=system-auth
auth required /lib/security/pam_nologin.so
account required /lib/security/pam_stack.so service=system-auth
password required /lib/security/pam_stack.so service=system-auth
session required /lib/security/pam_stack.so service=system-auth
session required /lib/security/pam_limits.so
session optional /lib/security/pam_console.so
, . PAM :
_ _ __ _
PAM :
auth . -, , , , . . -, ( group) , .
account , . , , , , .
sessions , . , , .
password (, ), .
, PAM , .
, . , . :
required , . , , , .
requisite , required, : , .
sufficient , required . , .
optional .
. /lib/security, , , pam_limits /lib/security/pam_limits.so.
.
, /etc/security. :
time.conf . pam_time, pam_time , .
pam_env.conf . pam_env.
limits.conf core-, , , , . pam_limits.
access.conf , , . pam_access.
group.conf , , . pam_time pam_group.
console.perms , . pam_console.
, /lib/security. , PAM, :
|
|
|
pam_cracklib |
password |
, , , . . , . : retry=N ; diffok=N , ; minlen=N ; dcredit=N ucredit=N lcredit=N ocredit=N , , , . |
pam_deny |
. |
|
pam_env |
auth |
. conffile=S , . |
pam_ftp |
auth |
. anonymous, , . : users=XXX, XXX, - ; ignore , . |
pam_group |
auth |
- , . |
pam_lastlog |
auth |
. wtmp, /var/log . : nodate noterm nohost silent , , ; never , . |
pam_limits |
session |
, . . conf=S . |
pam_listfile |
auth |
/etc/ftpaccess. : onerr=succeed | fail ; sence=allow | deny ; file=filename ; item=user | tty | rhost | ruser | group | shell . , item=user , , . |
pam_mail |
auth |
. : dir=S ; noenv MAIL; close ; nopen - . |
pam_nologin |
auth |
/etc/nologin , root, . |
pam_permit |
. ! |
|
pam_pwdb |
pam_unix. libpwdb, , . : nullok ; md5 shadow bigcrypt . |
|
pam_radius |
session |
RADIUS. |
pam_rhosts_auth |
auth |
hosts.equiv .rhosts, , rlogin rsh. : no_hosts_equiv hosts.equiv; no_rhosts - .rhosts; suppress , , sufficient. |
pam_root_ok |
auth |
, . , ( root). |
pam_securetty |
auth |
/etc/securetty. /etc/securetty , . |
pam_time |
account |
. |
pam_warn |
auth, password |
. |
pam_wheel |
auth |
. : group=XXX , root; deny , , root ; trust . |
PAM- , . PAM , . 5.
. . , . , , . , .
, , firewall ( . ) - , . , , , : , . , . , , . , . . , , , . , .
2.4.1.
. 2.4.1. Linux
), IP - -, MAC .
NAT (Network Address Translation) NPT (Network Port Translation). NAT IP - - . , IP . NPT NAT , IP .
TOS (Type Of Service), TTL (Time To Live) , .
netfilter , .
. , , . . , , .
. , .
Netfilter :
mangle . TTL, TOS MARK. : PREROUTING, POSTROUTING, INPUT, OUTPUT FORWARD. PREROUTING , . POSTROUTING . INPUT , . OUTPUT , . , , FORWARD , . , , .
nat , NAT, NPT. . . . PREROUTING . OUTPUT , , . POSTROUTING, . .
filter . . FORWARD, , , , . INPUT , . OUTPUT , .
netfilter 2.4.2.
, , , , , , . , , , , . , , . Linux , , , , .
2.4.2, , , . , PREROUTING mangle nat. , , , . , INPUT mangle filter. , . OUTPUT , , , POSTROUTING mangle nat. .
, , FORWARD mangle filter, . , , POSTROUTING mangle nat.
. . , , . , , INPUT, OUTPUT, FORWARD, PREROUTING POSTROUTING .
Linux iptables. , , :
iptables , . .
iptables-save , . /etc/sysconfig/iptables. /etc/sysconfig/iptables .
iptables-restore , iptables-save. /etc/sysconfig/iptables, .
iptables , man-.
6.
, .
, , . , . , - . , , . . , , . , , , , - . , , , . , . ?
. , . , , Telnet. , , . Telnet , . , , , network sniffer ( . ), .
Telnet UNIX- r-. rsh, rlogin ( r remote) , , . r-, Telnet, .
. SNMP (Simple Network Management Protocol). SNMP , Telnet.
, , , . , , , , , , .
, , SSH (Secure SHell). , SSH .
SSH 1995 , . SSH . , , . , . SSH Telnet, X11, SSH-, r- UNIX, .
SSH SSH , , : , . - Telnet .
, . . , SSH , , . , Telnet . TCP/IP, , . , .
SSH , , - , . , SSH. .
Linux UNIX- SSH - OpenSSH, , . OpenSSH , .
configure . , , SSH: IDEA, DES, DES, ARCFOUR BLOWFISH. IDEA, 128- . , 3DES - DES- c 56- . BLOWFISH, ( 32 448 ) IDEA DES. rlogin rsh SSH. SSH, , . r-. , , help.
, , OpenSSH /usr/local/etc/ssh. , sshd_config ssh_config .
<> <>
, , , , , SSH ( : SSH 1.0 SSH 2.0) . sshd_config , sshd ( 22), IP . , OpenSSH.
7.
.
, Linux. , Linux . . ext2, chmod chown, , chattr lsattr. lcap . , quota. , , PAM, , , , . PAM. netfilter, , . SSH, , .
Linux , , . Linux . , , . .
. , , . . Linux , -, - . - Linux . , .
Linux ACLs.
Linux ACLs (Access Control Lists) , - - , .
Linux ACLs . . . ACL :
ACL_USER_OBJ -;
ACL_GROUP_OBJ -;
ACL_OTHER .
ACL :
ACL_USER UID , , . . ;
ACL_GROUP , ACL_USER, ;
ACL_MASK .
ACL_MASK.
. ACL, . ACL, ACL .
Linux ACLs Linux ACLs Linux . , , . . ACL, . . Linux ACLs, ACL, .
Linux ACLs , ACL getfacl setfacl. . . man- .
LIDS (Linux Intrusion Detection/Defence System) . Linux, . LIDS , , , , .
Linux, , LIDS, , LIDS. LIDS. : LIDS, .
, LIDS, , LIDS . LIDS LIDS. LIDS .
LIDS /etc lids, :
lids.cap .
lids.net LIDS.
lids.pw . lidsadm LIDS.
lids.conf . lidsadm.
LIDS .
- .
/etc/lids/lids.cap. :
[ + | - ] <>:<>
+ , .
.
.
/etc/lids/lids.cap . , , , lidsadm.
/etc/lids/lids.cap :
CAP_CHOWN - ;
CAP_DAC_OVERRIDE , , . root , ;
CAP_DAC_READ_SEARCH , CAP_DAC_OVERRIDE, ;
CAP_FOWNER , , ;
CAP_FSETID SUID SGID , root;
CAP_KILL ;
CAP_SETGID, CAP_SETUID , ;
CAP_SETPCAP ;
CAP_LINUX_IMMUTABLE immutable append ;
CAP_NET_BIND_SERVICE , root, 1024;
CAP_NET_ADMIN : , , , Linux;
CAP_NET_RAW ;
CAP_IPC_LOCK ;
CAP_IPC_OWNER root , root;
CAP_SYS_MODULE ;
CAP_SYS_RAWIO / , /dev/mem, /dev/kmem, /dev/port, /dev/hd*, /dev/sd*;
CAP_SYS_CHROOT ;
CAP_SYS_PTRACE ptrace(), - -;
CAP_SYS_PACCT ;
CAP_SYS_ADMIN : /dev/random, , , klogd, , , , , ;
CAP_SYS_BOOT ;
CAP_SYS_NICE , ;
CAP_SYS_RESOURCE : , ext2, ;
CAP_SYS_TIME ;
CAP_SYS_TTY_CONFIG tty;
CAP_HIDDEN . ;
CAP_INIT_KILL - init;
,
lidsadm I
, .
LIDS . LIDS lidsadm. : . /etc/lids/lids.conf. lidsadm L.
[root@app /]# lidsadm L
LIST
Subject ACCESS TYPE Object
-------------------------------------------------------------
Any File READ /sbin
Any File READ /bin
Any File READ /boot
Any File READ /lib
Any File READ /usr
Any File DENY /etc/shadow
/bin/login READ /etc/shadow
/bin/su READ /etc/shadow
Any File APPEND /var/log
Any File WRITE /var/log/wtmp
: , . , LIDS. , .
, . , , LIDS, . , .
. :
READ ;
WRITE ;
DENY - ;
APPEND ;
IGNORE .
man-.
AIDE (Advanced Intrusion Detection Environment) . AIDE , , , , , , Linux.
AIDE , aide.conf. , : SHA1, MD5, RMD160, TIGER.
, , AIDE. . , , , , , .
aide init.
[root@gw /]# aide init
, root . - , .
aide check.
[root@gw /]# aide check
. .
AIDE , . , AIDE, , . , , .
.
, Linux . Linux ACLs, , getfacl setfacl . LIDS, 2.4 LIDS . . AIDE, , .
. .
, , , . , . , . , , - . , , , .
40- . , , , - . , , , . , .
, , .
: , .
. , . .
. , . .
, , , , , , , , , , .
- , , , .
, , , . 1% 1/2. , , .
, . , , . , ( ).
, - , , , , , , - .
:
. , , - , 90- 1,5 2,5 .
4.1.
4.1.
|
|||
,
,
,
,
,
,
|
30-330 0,3-3 3-30 30-300 300-3000 3-30 |
10-1 1-0,1 100-10 10-1 1-0,1 10-1 |
25 / 15 / 10 / 3 / 10 /2 10 /2 |
. , , . . , , .
, , , 50-70 .
.
:
2 .
, , , , . , , , .
(Total Shield), - , .
.
, - , . , , , .
, Linux , .
:
Linux, , , passwd, shadow, useradd, usermod userdel, passwd, ;
ext2, , chmod chown, , chattr lsattr, lcap, , quota, , ;
PAM, , PAM, PAM , PAM, ;
netfilter, netfilter, iptables, iptables Linux, ;
Telnet, rsh, SNMP, SSH, OpenSSH, sshd, SSH;
Linux ACLs, , getfacl setfacl;
LIDS, 2.4, LIDS;
AIDE, , .
. , , - . Linux, , . . .
1. Linux. , -, -, 2002.
2. Linux.
1.
: Linux RedHat 7.3 . .
: . anna pavel, systemuser .
.
:
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/etc/news:
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
rpm:x:37:37::/var/lib/rpm:/bin/bash
, .
: adm, lp, shutdown, halt, news, operator, games, gopher, ftp. lp , . , . shutdown halt , . news, gopher ftp , , GOPHER FTP-. games , , .
userdel <_>
:
[root@gw /]# userdel adm
[root@gw /]# userdel lp
[root@gw /]# userdel shutdown
[root@gw /]# userdel halt
[root@gw /]# userdel news
[root@gw /]# userdel operator
[root@gw /]# userdel games
[root@gw /]# userdel gopher
[root@gw /]# userdel ftp
. .
[root@gw /]# useradd m s /bin/bash c Normal User d /home/pavel g users pavel
[root@gw /]# useradd m s /bin/bash c Normal User d /home/pavel g users anna
[root@gw /]# useradd r s /sbin/nologin c System User d /var/empty systemuser
, , . .
[root@gw /]# passwd anna
Changing password for user anna.
New password: <_>
Retype new password: <__>
passwd: all authentication tokens updated successfully.
[root@gw /]# passwd pavel
Changing password for user pavel.
New password: <_>
Retype new password: <__>
passwd: all authentication tokens updated successfully.
, anna pavel, .
2.
: Linux RedHat 7.3 . . web- Apache, FTP- Proftpd. Web- nobody, FTP- ftpuser. nogroup. web-, . 2 : . FTP, web-. .
: web- .
.
, , web-, /www. , /www ftp html: FTP , HTTP. , /www, nobody ftpuser. , /www/ftp, ftpuser, nobody. , /www/html nobody . , , .
, nobody ftpuser nogroup, /www :
[root@app /]# chmod 050 /www
[root@app /]# chown root:nogroup /www
[root@app /]# ls l
d---r-x--- 1 root nogroup 4096 7 19:48 www
- . - nogroup. . , www , - - .
, www , www.
[root@app www]# chown R ftpuser:nogroup /www/ftp
[root@app www]# chmod R o-rwx /www/ftp
[root@app www]# chmod R ug+rw /www/ftp
[root@app www]# chown R nobody:root /www/html
[root@app www]# chmod R go-rwx /www/html
[root@app www]# chmod R u+r /www/html
[root@app www]# ls l /www
drwxrwx--- 1 ftpuser nogroup 4096 7 19:55 ftp
dr-x------ 1 nobody root 4096 7 20:01 html
- - ftp, , - -. R , . chown R nobody:root /www/html - html nobody. chmod R go-rwx /www/html - . chmod R u+r /www/html -. . !
: , 022 (umask 022). , , .
3.
: Linux RedHat 7.3 . lcap. .
: ( , immutable).
.
, , , , . .
, , , :
/boot /etc . /etc - .
/bin , , .
/sbin , .
/lib , .
immutable , .
[root@app /]# chattr R +i /boot /etc /bin /sbin /lib
[root@app /]# lsattr
---i---------- ./boot
---i---------- ./etc
-------------- ./root
---i---------- ./bin
-------------- ./initrd
---i---------- ./lib
---i---------- ./sbin
R , .
/usr . immutable:
/usr/bin /usr/sbin /usr/lib /usr/local/bin /usr/local/sbin /usr/local/lib , .
/usr/include /usr/local/include . , , .
[root@app /]# chattr R +i /usr/bin /usr/sbin /usr/lib /usr/include
[root@app /]# lsattr /usr
-------------- /usr/lost+found
---i---------- /usr/bin
---i---------- /usr/lib
-------------- /usr/libexec
---i---------- /usr/sbin
---i---------- /usr/include
-------------- /usr/local
---i---------- /usr/src
lcap CAP_LINUX_IMMUTABLE CAP_SYS_RAWIO:
[root@app /]# lcap CAP_LINUX_IMMUTABLE
[root@app /]# lcap CAP_SYS_RAWIO
, .
, , , .
4.
: Linux RedHat 7.3 . - . 2.4.20, , quota-3.11. /dev/hda3 25 , /home.
: . 10 1000.
.
. /etc/fstab /home usrquota grpquota, , . usrquota.
/etc/fstab, /home, :
/dev/hda3 /home ext2 default,usrquota 1 2
2.4 , , . .
. , quotacheck, quotaon. , man-, quota. , , :
quotacheck aug
quotaon aug
a , , fstab, , NFS. u , /etc/mtab. /etc/mtab , . g , u, . , , , , .
, . Linux RedHat /etc/rc.d/init.d/rc.sysinit. , quotacheck quoaton , . , Linux RedHat , . Linux , , .
quotacheck , , quotacheck . /home aquota.user, .
, setquota, , /home. :
[root@app /]# setquota u <_> 10240 0 1000 0 /dev/hda3
10 1000 . anna :
[root@app /]# setquota u anna 10240 0 1000 0 /dev/hda3
, , anna . igor anna :
[root@app /]# setquota u p anna igor /dev/hda3
igor , anna, 10 1000 . .
repquota. a .
[root@app /]# repquota -a
*** Report for user quotas on device /dev/hda3
Block grace time: 00:00; Inode grace time: 00:00
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------
...
anna -- 4 2097152 0 1 0 0
igor -- 4 2097152 0 1 0 0
...
, aquota.user . - cron, Linux. . quotacheck quotaoff. , , /usr/sbin/chkquota, :
#!/bin/bash
# Turn off quotas
quotaoff aug
# Check quotas
quotacheck aug
# Turn on quotas
quotaon aug
/etc/crontab cron :
0 3 * * 0 root /usr/sbin/chkquota
. /etc/crontab man-, cron.
5.
: Linux RedHat 7.3 . - . pam-0.75-32.
: , , users. 20, 30 - .
.
pam_limits. /etc/security/limits.conf, . , . :
<_> <> <_> <>
, , @ , *, , . @users.
soft, hard. soft , hard . .
, . :
nproc . 20.
nofile . 30.
core . 0.
/etc/security/limits.conf :
@users hard nproc 20
@users hard nofile 30
@users hard core 0
, , pam_limits PAM. login, /etc/pam.d. /etc/pam.d/login :
#%PAM-1.0
auth required pam_securetty.so
auth required pam_stack.so service=system-auth
auth required pam_nologin.so
account required pam_stack.so service=system-auth
password required pam_stack.so service=system-auth
session required pam_stack.so service=system-auth
session optional pam_console.so
session required pam_limits.so
PAM pam_limits, .
ssh pam_limits /etc/pam.d/sshd. :
#%PAM-1.0
auth required pam_stack.so service=system-auth
auth required pam_nologin.so
account required pam_stack.so service=system-auth
password required pam_stack.so service=system-auth
session required pam_stack.so service=system-auth
session optional pam_console.so
session required pam_limits.so
, users .
6.
: Linux RedHat 7.3 . - . iptables-1.2.5, 2.4.22, netfilter iptables. . eth0 eth1 TCP/IP IP . 192.168.0.0, 192.168.1.0, 255.255.255.0. eth0 IP 192.168.0.1, eth1 192.168.1.1. eth2 144.333.333.333 .
: . HTTP-, , SMTP, DNS, SSH. POP3. , 192.168.0.0 , 192.168.1.0 IP 192.168.1.30 192.168.1.45.
.
, ip_forward. , 1 , /etc/sysctl.conf , , net.ipv4.ip_forward = 0 0 1. , . , , , , . .
[root@app /]# echo 1 > /proc/sys/net/ipv4/ip_forward
, , .
[root@app /]# /sbin/iptables t filter -P INPUT DROP
[root@app /]# /sbin/iptables t filter -P OUTPUT DROP
[root@app /]# /sbin/iptables t filter -P FORWARD DROP
, INPUT, OUTPUT FORWARD. DROP , , . t , . , filter, .
filter .
[root@app /]# /sbin/iptables -N bad_tcp_packets
[root@app /]# /sbin/iptables -N allowed
[root@app /]# /sbin/iptables -N tcp_packets
[root@app /]# /sbin/iptables -N udp_packets
[root@app /]# /sbin/iptables -N icmp_packets
bad_tcp_packets "" . , NEW, , , SYN , , , , SYN/ACK-, NEW. .
[root@app /]# /sbin/iptables -A bad_tcp_packets -p tcp --tcp-flags SYN,ACK SYN,ACK -m state --state NEW -j REJECT --reject-with tcp-reset
[root@app /]# /sbin/iptables -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j LOG --log-prefix "New not syn:"
[root@app /]# /sbin/iptables -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j DROP
tcp_packets . tcp- . , . , , . allowed .
[root@app /]# /sbin/iptables -A tcp_packets -p TCP --dport 22 -j allowed
[root@app /]# /sbin/iptables -A tcp_packets -p TCP --dport 25 -j allowed
[root@app /]# /sbin/iptables -A tcp_packets -p TCP --dport 80 -j allowed
[root@app /]# /sbin/iptables -A tcp_packets -p TCP i eth0 --dport 110 -j allowed
[root@app /]# /sbin/iptables -A tcp_packets -p TCP i eth1--dport 110 -j allowed
allowed tcp , tcp_packets . , SYN, , . . , ESTABLISHED, RELATED, . , . , .
[root@app /]# /sbin/iptables -A allowed -p TCP --syn -j ACCEPT
[root@app /]# /sbin/iptables -A allowed -p TCP -m state --state ESTABLISHED,RELATED -j ACCEPT
[root@app /]# /sbin/iptables -A allowed -p TCP -j DROP
udp_packets , tcp_packets, udp-. DNS UDP , , DNS, .
[root@app /]# /sbin/iptables -A udp_packets -p UDP --dport 53 -j ACCEPT
icmp_packets icmp-. Linux : ICMP Echo Request Time Exceeded.
[root@app /]# /sbin/iptables -A icmp_packets -p ICMP --icmp-type 8 -j ACCEPT
[root@app /]# /sbin/iptables -A icmp_packets -p ICMP --icmp-type 11 -j ACCEPT
, t filter.
. INPUT filter.
[root@app /]# /sbin/iptables -A INPUT -p tcp -j bad_tcp_packets
[root@app /]# /sbin/iptables -A INPUT -i lo s 127.0.0.0/8 -j ACCEPT
[root@app /]# /sbin/iptables -A INPUT -i lo -s 192.168.0.1 -j ACCEPT
[root@app /]# /sbin/iptables -A INPUT -i lo -s 192.168.1.1 -j ACCEPT
[root@app /]# /sbin/iptables -A INPUT -i lo -s 144.333.333.333 -j ACCEPT
[root@app /]# /sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
[root@app /]# /sbin/iptables -A INPUT p TCP -j tcp_packets
[root@app /]# /sbin/iptables -A INPUT -p UDP -j udp_packets
[root@app /]# /sbin/iptables -A INPUT -p ICMP -j icmp_packets
[root@app /]# /sbin/iptables -A INPUT -m limit --limit 3/minute --limit-burst 3 -j LOG --log-level DEBUG --log-prefix "IPT INPUT packet died: "
bad_tcp_packets . , . , . . (RELATED ESTABLISHED), . , 99- , , , , .
, , . TCP, UDP ICMP . , ACCEPT, , ( LOG), INPUT, .
[root@app /]# /sbin/iptables -A FORWARD -p tcp -j bad_tcp_packets
[root@app /]# /sbin/iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
[root@app /]# /sbin/iptables -A FORWARD -i eth0 s 192.168.0.0/24 -j ACCEPT
[root@app /]# /sbin/iptables -A FORWARD -i eth1 s 192.168.1.30 -j ACCEPT
[root@app /]# /sbin/iptables -A FORWARD -i eth1 s 192.168.1.45 -j ACCEPT
[root@app /]# /sbin/iptables -A FORWARD -m limit --limit 3/minute --limit-burst 3 -j LOG --log-level DEBUG --log-prefix "IPT FORWARD packet died: "
INPUT, , , bad_tcp_packets. . , eth0, 192.168.0.0, , 192.168.0.0 . , NAT, .
[root@app /]# /sbin/iptables -t nat -A POSTROUTING -o eth2 -j SNAT --to-source 144.333.333.333
POSTROUTING nat , - , eth2, , , . , , .
[root@app /]# /sbin/iptables -A OUTPUT -p tcp -j bad_tcp_packets
[root@app /]# /sbin/iptables -A OUTPUT -s 127.0.0.0/8 -j ACCEPT
[root@app /]# /sbin/iptables -A OUTPUT -s 192.168.0.1 -j ACCEPT
[root@app /]# /sbin/iptables -A OUTPUT -s 192.168.1.1 -j ACCEPT
[root@app /]# /sbin/iptables -A OUTPUT -s 144.333.333.333 -j ACCEPT
[root@app /]# /sbin/iptables -A OUTPUT -m limit --limit 3/minute --limit-burst 3 -j LOG --log-level DEBUG --log-prefix "IPT OUTPUT packet died: "
OUTPUT , IP . , .
[root@app /]# /sbin/iptables-save > /etc/sysconfig/iptables
.
.
7.
: Linux RedHat 7.3 . . OpenSSH-3.6.1p2.
: SSH SSH 1.0.
.
1.0 SSH , . 2.0 , . SSH , , . 1.0, sshd_config
Protocol 2
sshd 2.0. , 1.0, .
OpenSSH 3.6 UsePrivilegeSeparation, sshd . , , sshd, , sshd, . OpenSSH, , root. , . sshd_config
UsePrivilegeSeparation yes
, . OpenSSH .
, PermitRootLogin.
PermitRootLogin no
root . root su.
AllowGroups, DenyGroups AllowUsers, DenyUsers . , wheel,
DenyGroups *
AllowGroups wheel
. . MaxStartups sshd, , . 10. , 5. LoginGraceTime , , , . 2 . , . , 30 , , , , , 60 .
,
Protocol 2
UsePrivilegeSeparation yes
PermitRootLogin no
MaxStartups 5
LoginGraceTime 30
SSH , - . , .
Copyright (c) 2024 Stud-Baza.ru , , , .