Tài liệu Operational Administration Recovery and Security ppt

42 420 0
Tài liệu Operational Administration Recovery and Security ppt

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

11 Operational Administration Recovery and Security CERTIFICATION OBJECTIVES 11.01 Services and Special Users 11.02 Red Hat User Private Group Scheme 11.03 tmpwatch 11.04 The Linux Rescue Process 11.05 The Secure Shell Package ✓ Two-Minute Drill Q&A Self Test CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 Blind Folio 11:625 D:\omh\CertPrs8\485-1\ch11.vp Wednesday, September 18, 2002 10:28:34 AM Color profile: Generic CMYK printer profile Composite Default screen T he themes of this chapter are security and recovery. These are two critical concepts for the RHCE exam. This continues the discussion of system security started in the last chapter, with a look at secure ways to run certain network services and a Red Hat Linux–specific way of specifying file security. This chapter includes a description of setting up security with groups. You can set up special groups in Red Hat Linux. The users in these groups have access to a common directory. Next, you’ll learn about the part of the administrative process related to maintaining your temporary directories with the tmpwatch utility. Also discussed is one of the most fundamental and important topics of concern to any systems administrator: what to do when a system will not boot. When the inevitable happens, knowing the right things to look for and having some tricks up your sleeve may possibly help you avoid a potential nightmare and a major loss of service for your users. Understanding these tools is fundamental to getting through the RHCE Debug exam. CERTIFICATION OBJECTIVE 11.01 Services and Special Users The programs that run on Linux are all processes. When Red Hat Linux starts on your computer, it first starts a special process known as init. The init process then starts other basic processes required for a working Linux system, including the shell, the basic user consoles, startup daemons, and more. Because it needs the authority, init runs as root. Interestingly enough, most other services, especially network daemons, do not run under the root user ID. This is one important way Linux protects your network security. Suppose you have configured a system to start several network services running under the root user ID. Even if you loaded the latest security patches, the risk is still high. If a cracker stumbles upon your system and is able to break in, he or she can quickly get root access through the service daemon. To circumvent problems like this, Red Hat Linux normally configures services to run under their own user accounts. If a cracker does succeed in breaking into one CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 626 Chapter 11: Operational Administration Recovery and Security CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 D:\omh\CertPrs8\485-1\ch11.vp Wednesday, September 18, 2002 10:28:34 AM Color profile: Generic CMYK printer profile Composite Default screen CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 daemon, the damage is limited because the service is running as a normal, unprivileged user. Alternatively, some services can be run through the nobody account. Figure 11-1 shows a typical /etc/passwd file. Notice that most common network services have their own user accounts. EXERCISE 11-1 Verifying That Services Have Their Own Accounts In this exercise, you will verify that certain system and network services run with their own accounts. You should try this exercise on a system that is configured to offer various network services. At a shell prompt, issue the following command: [root]# ps aux --headers | less What account is the Web server (httpd) running under? What account is the xfs service running under? Services and Special Users 627 CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 FIGURE 11-1 Services have their own accounts in /etc/passwd. D:\omh\CertPrs8\485-1\ch11.vp Wednesday, September 18, 2002 10:28:34 AM Color profile: Generic CMYK printer profile Composite Default screen CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 CERTIFICATION OBJECTIVE 11.02 Red Hat User Private Group Scheme One major difference between Red Hat Linux and other versions of Unix or Linux is how new users are assigned to groups. Traditionally, users are assigned to one or more groups such as users in /etc/group. For example, you might configure accgrp for the accounting department and infosys for the information systems department in your company. If you have access to one of these other versions of Unix or Linux, check the third and fourth fields in /etc/passwd. Many users will have the same fourth field, which represents their primary group. Then, when you create a new user, each account receives a unique user ID but shares the same group ID with other users in the acct group. Users can still belong to other groups as well. On the other hand, Red Hat Linux normally gives each user a unique user ID and group ID in /etc/passwd. This is known as the user private group scheme. A Linux group allows its members to share files. Unfortunately, that also means everyone in the same primary group has access to the home directories of all other group members. Users may not always want to share the files in their home directories with others. For example, if you’re setting up an ISP, your users pay for their privacy. With Linux, you can set up a specific shared directory for a secondary group. The group ownership of a new directory can be reconfigured for all members of that group. All authorized users are added to the appropriate entry in /etc/group. When you set the group ID bit (SGID) on this directory, any file created in this directory inherits the group ID. Assuming you have set appropriate permissions, all group members can then access files in that the directory. For example, suppose you have a group set up for the users in the accounting department called accgrp, and you would like to create a shared directory called accshared under /home: # mkdir /home/accshared # chown nobody:accgrp /home/accshared # chmod 2770 /home/accshared Any user who is a member of the accgrp group can now create files in the /home/accshared directory. Any files generated will then be associated with the accgrp group ID, and all users listed on the accgrp line in the /etc/group file will have read, write, and execute access to the accshared directory. 628 Chapter 11: Operational Administration Recovery and Security CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 D:\omh\CertPrs8\485-1\ch11.vp Wednesday, September 18, 2002 10:28:34 AM Color profile: Generic CMYK printer profile Composite Default screen CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 [root]# grep accgrp /etc/group accgrp:x:1212:stewardh,jamiec,davidw,debl,callend,vanessar The permissions associated with the chmod 2770 /home/accshared command are important. Otherwise, users who are members of accgrp and belong to another primary group would have to remember to use the chgrp command on every file they put in /home/accshared. While clumsy, that command allows other users in that group to access the file. But it isn’t necessary. The solution to this particular problem is the set group ID bit, or the SGID bit. When the SGID bit is set for a directory, any files created in that directory automatically have their group ownership set to be that of the group owner of the directory. There are two ways to set the SGID bit for the /home/accshared directory: chmod g+s /home/accshared or alternatively: chmod 2770 /home/accshared Setting the SGID bit solves the problem of making sure all files created in a shared directory belong to the correct group—as long as the umask is set properly. By default in Red Hat Linux, all regular users have a umask of 0002. If you are coming from a traditional Unix environment, you may be concerned. With the traditional user/group scheme, any member of that user’s primary group will automatically have write access to any file that the user creates in his home directory. This is the advantage behind the user private group scheme. Since every user account is the only member in its own private group, having the umask set to 002 does not affect file security. EXERCISE 11-2 Controlling Group Ownership with the SGID Bit In this exercise, you will create new files in a directory where the SGID bit is set. 1. Add users called test1, test2, and test3. Check the /etc/passwd and /etc/group files to verify that each user’s private group was created: # /usr/sbin/useradd test1; passwd test1 # /usr/sbin/useradd test2; passwd test2 # /usr/sbin/useradd test3; passwd test3 Red Hat User Private Group Scheme 629 CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 D:\omh\CertPrs8\485-1\ch11.vp Wednesday, September 18, 2002 10:28:34 AM Color profile: Generic CMYK printer profile Composite Default screen CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 2. Edit the /etc/group file and add a group called tg1. Make the test1 and test2 accounts a member of this group. The line you add should look like this: # echo 'tg1::9999:test1,test2' >> /etc/group Make sure the group ID you assign to group tg1 is not already in use. 3. Create a shared director for the tg1 group: # mkdir /home/testshared 4. Change the user and group ownership of the shared directory: # chown nobody.tg1 /home/testshared 5. Log in as test1 and test2 separately. Change the directory to the testshared directory and try to create a file. What happens? [test1]$ date >>test.txt 6. Now as the root user, set group write permissions on the testshared directory. Log in again as user test1, and then try to create a file. Check the ownership on the file: # chmod 770 /home/testshared [test1]$ date >>test.txt [test1]$ ls -l test.txt 7. From the root account, set the SGID bit on the directory: [root]# chmod g+s /home/testshared 8. Switch back to the test1 account and create another file. Check the ownership on this file: [test1]$ date >> testb.txt [test1]$ ls -l 9. Now log in as the test2 account. Go into the /home/testshared directory, create a different file, and use ls -l to check permissions and ownership again. 10. Switch to the test3 account and check whether you can or cannot create files in this directory, and whether you can or cannot view the files in this directory. 630 Chapter 11: Operational Administration Recovery and Security CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 D:\omh\CertPrs8\485-1\ch11.vp Wednesday, September 18, 2002 10:28:34 AM Color profile: Generic CMYK printer profile Composite Default screen CERTIFICATION OBJECTIVE 11.03 tmpwatch The tmpwatch command (/usr/sbin/tmpwatch) is used to remove files that have not been accessed in a specified number of hours. As its name implies, it is normally run on directories such as /tmp and /var/tmp. The tmpwatch command works recursively, so if you specify the top-level directory in a tree, tmpwatch will search through the entire directory tree looking for files to remove. Here is an example, which uses tmpwatch to delete all files in the /tmp directory that haven’t been accessed within a week (7×24 = 168 hours): /usr/sbin/tmpwatch 168 /tmp Although you can run the tmpwatch command from the command line, it is often more practical to set it up to be run by the cron daemon on a regular basis. By default, Red Hat Linux sets up tmpwatch to delete files in /tmp and /var/tmp every 10 and 30 days, respectively. EXERCISE 11-3 Clearing an Imaginary /db Directory In a bizarre twist of fate, a runaway process has just created 200 temporary files in /db that it did not remove. You could remove them manually, or you can let tmpwatch delete all the files that are more than one hour old. Note that this removes all files over an hour old, not just these imaginary files, so this should not be done on a production server directory. If you have /db, do not use it. If necessary, create a separate directory just for the purpose of this exercise. [root]# cp /etc/* /db # copying a large number of files to /db [root]# ls /db | wc -w # how may files need to be removed Wait at least an hour. [root]# /usr/sbin/tmpwatch 1 /db [root]# ls /db # files should be gone CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 tmpwatch 631 CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 D:\omh\CertPrs8\485-1\ch11.vp Wednesday, September 18, 2002 10:28:35 AM Color profile: Generic CMYK printer profile Composite Default screen Alternatively, you can copy or extract files from an older backup or tar archive to the /db directory, and have tmpwatch delete them. If they are all more than seven days old, then use 168 as the waiting period. You could even try various times to see which files are deleted. CERTIFICATION OBJECTIVE 11.04 The Linux Rescue Process At some point in your career as a Red Hat Linux systems administrator, maybe even on the RHCE exam, you’re going to be faced with a system that will not boot. It will be up to you to determine the cause of the problem and implement a fix. Sometimes, the problem may be due to hardware failure: the system in question has a bad power supply or has experienced a hard disk crash. Quite often, however, the failure of a system to boot can be traced back to the actions of a user: you, the system administrator! When you are editing certain system configuration files, typographical errors can render your system unbootable. Any time you plan to make any substantial modifications to your system or change key configuration files, back them up first. Then, after making changes, you should actually reboot your system rather than assume that it will boot up the next time you need a reboot. It’s much better to encounter problems while you can still remember exactly which changes you made. It is even better if you can go back to a working configuration file. To prepare for boot failures, you should make sure you have a valid boot floppy for your system. But boot floppies can be lost. So it’s also important to know how to use the Red Hat installation boot disk or CD to get to the linux rescue mode, first discussed in Chapter 3. Refer to that chapter for more information on creating a installation boot disk. Know every detail that you can about linux rescue mode. 632 Chapter 11: Operational Administration Recovery and Security CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 D:\omh\CertPrs8\485-1\ch11.vp Wednesday, September 18, 2002 10:28:35 AM Color profile: Generic CMYK printer profile Composite Default screen A mkbootdisk Boot Floppy When you installed Red Hat Linux, the last screen may have asked whether you wanted a boot disk. If you answered No to this prompt, you can still create a valid boot floppy for your computer using the /sbin/mkbootdisk command. The /sbin/mkbootdisk command reads the selected kernel images in /boot and the default boot loader, GRUB or LILO, to create a LILO-style boot image on a floppy disk. For example, if your current kernel is version 2.4.24-2, use this command: [root]# mkbootdisk 2.4.24-2 You may be able to fix a few problems, such as accidentally deleting your master boot record, by booting from your boot disk. If the kernel can’t locate the root filesystem, or if the root filesystem is damaged, the Linux kernel will issue a kernel panic and halt as shown in the following code: Creating root device Mounting root filesystem kjournald starting. Commit interval 5 seconds EXT3-fs: mounted filesystems with ordered data mode. pivotroot: pivot_root (/sysroot,/sysroot/initrd) failed: 2) Freeing unused kernel memory: 272k freed Kernel panic: No init found. Try passing init= option to kernel Although this may look very bad the first time you encounter it, often the problem can easily be fixed from rescue mode with a little bit of work. Other problems may also require the use of rescue mode. Installation Disk Rescue Mode As discussed in Chapter 3, you can start Linux in rescue mode from the Red Hat Linux installation CD or boot disk. When you type linux rescue at the installation boot prompt, a compact version of a root filesystem is installed. As this information has to fit on a 1.44MB floppy disk, it includes a minimal set of utilities that will allow you to mount a disk and either repair the problem with the disk or edit the broken files on the disk. To boot into rescue mode, first boot your system either using your boot floppy or directly with the first binary CD in a bootable CD-ROM drive, as shown in Figure 11-2. At the boot: prompt, type linux rescue and press ENTER . At first, it’s as if rescue mode isn’t working; you’re taken through the first steps of Red Hat Linux installation, The Linux Rescue Process 633 CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 D:\omh\CertPrs8\485-1\ch11.vp Wednesday, September 18, 2002 10:28:35 AM Color profile: Generic CMYK printer profile Composite Default screen in text mode. You’ll need to enter a language, a keyboard type, and the location of the Red Hat Linux installation files. If you started linux rescue from a bootnet.img floppy, you may also need the network location of the Red Hat Linux installation files. Once the files associated with linux rescue mode are loaded, you’ll see the screen shown in Figure 11-3. As you can see, you now have three choices: ■ Continue will search through and mount the available filesystems. ■ Read-Only performs the same tasks as Continue, except all filesystems that are found are mounted read-only. ■ Skip does not try to look through the available filesystems. Instead, it proceeds directly to a root shell prompt. Standard Linux Rescue Mode When you select Continue in Figure 11-3, you’re taken through the standard Linux rescue mode. The rescue files search for your root directory (/) filesystem. If found, 634 Chapter 11: Operational Administration Recovery and Security CertPrs8 / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 FIGURE 11-2 Entering rescue mode from an installation disk D:\omh\CertPrs8\485-1\ch11.vp Wednesday, September 18, 2002 10:28:35 AM Color profile: Generic CMYK printer profile Composite Default screen [...]... Jang / 222485-1 / Chapter 11 Operational Administration Recovery and Security Unix and the network that became the Internet started in an educational setting, where there is a premium on the free exchange of information While the resulting openness of the Internet is good, it can present security challenges The original Unix tools developed for networks were not designed with security in mind These tools... Chapter 11: / RHCE Red Hat Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 Operational Administration Recovery and Security The Linux implementation of PGP is known as GPG, the Gnu Privacy Guard GPG is an implementation of the OpenPGP standard Both standards are now common ways people and companies protect their correspondence *********************************************************************... 222485-1 / Chapter 11 Operational Administration Recovery and Security SELF TEST The following questions will help you measure your understanding of the material presented in this chapter Read all the choices carefully, as there may be more than one correct answer Choose all correct answers for each question Services and Special Users 1 You are setting up a Red Hat Linux system and are adding several... Chapter 11 Operational Administration Recovery and Security 9 How would you obtain a boot disk if you don’t have one? A Order one from Red Hat B Run the mkrescuedisk utility C Place a floppy in the floppy drive, mount the latest Red Hat distribution CD, and issue the command cp /mnt/cdrom/images/rescue.img /dev/fd0 D Place a floppy in the floppy drive, mount the latest Red Hat distribution CD, and issue... Guide / Jang / 222485-1 / Chapter 11 Operational Administration Recovery and Security 11 Edit the bad stanza in grub.conf and fix the problems: # vi /tmpmnt/boot/grub/grub.conf 12 Your new version should look like this: title badboot root=(hd0,0) kernel /vmlinuz-2.4.18-5.58 initrd /initrd-2.4.18-5.58.img 13 Save your changes to the grub.conf file 14 Sync your changes and unmount any mounted partitions:... Certified Engineer Linux Study Guide / Jang / 222485-1 / Chapter 11 Operational Administration Recovery and Security FIGURE 11-4 Linux rescue mounted your root directory Sometimes an unmounted filesystem just needs a little cleaning; remember, a command such as the following cleans the /dev/sdb1 partition # fsck /dev/sdb1 The fsck command works only on an unmounted filesystem Remember the message in... 222485-1 / Chapter 11 The Linux Rescue Process 637 This command allows you to run any commands or utilities that may be sensitive to the PATH such as the man command So if you need to look up some man documentation, run the chroot /mnt/sysimage command first When you’ve made your changes, run the sync command three times and type the exit command Linux should automatically stop, allowing you to reboot... Study Guide / Jang / 222485-1 / Chapter 11 Operational Administration Recovery and Security CERTIFICATION SUMMARY As you’ve seen in the past two chapters, there are many facets to system security Making sure that network services run under nonprivileged accounts helps minimize the risks associated with outside attack By default, Red Hat Linux assigns unique user and group ID numbers to each new user This... command This command is a front end for most of the filesystem formats available in Linux, such as ext2, ext3, reiserfs, and more This command is used to check the filesystem on a partition for consistency In order to effectively use the fsck command, you need to understand something about how filesystems are laid out on disk partitions When you format a disk partition under Linux using the mkfs command,... command with the -b option to specify an alternative superblock For example, the command: # fsck -b 8193 /dev/hda5 tells fsck to perform a consistency check on the filesystem on disk partition /dev/hda5, using the superblock located at disk block 8193 Get to know the key commands and the associated options for checking disks and partitions: fdisk , e2label, dumpe2fs, and fsck Practice using these commands . 11 Operational Administration Recovery and Security CERTIFICATION OBJECTIVES 11.01 Services and Special Users 11.02 Red Hat. this directory, and whether you can or cannot view the files in this directory. 630 Chapter 11: Operational Administration Recovery and Security CertPrs8

Ngày đăng: 11/12/2013, 00:15

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan