You've forgotten the root password for ServerA.
Securely reset the root password to regain access to the system.
Remember, resetting a root password should only be done as a last resort, and strong password practices should be followed after regaining access.
answere)
reboote를 누른다.Ctrl+e를 누른다.rd.break를 추가Ctrl + x를 눌러 수정된 parameter와 함께 emergency mode로 bootmount -o remount,rw /sysrootchroot /sysrootpasswd root (주의: 강력한 비밀번호 설정 필요)touch /.autorelabelexit 2번(chroot와 emergency shell을 순서대로 벗어나기 위해)validation
Configure a Local Yum/DNF Repository on ServerA using the RHEL-9 ISO image mounted on the /mnt directory.
answere)
mount -o loop RHEL-9.iso /mnt-o loop: 일반 파일을 블록디바이스처럼 다루는 것. mount는 원래 블록디바이스에 대해서만 명령어 사용 가능 mount /dev/sr0 /mntcp /mnt/media.repo /etc/yum.repos.d/rhel9.repovi /etc/yum.repos.d/rhel9.repo[BaseOS]
name=BaseOS
enabled=1
gpgcheck=0
baseurl=file:///mnt/BaseOS
[AppStream]
name=AppStream
enabled=1
gpgcheck=0
baseurl=file:///mnt/AppStream
metadata_expire=-1: metadata expiration을 disable
gpgcheck=0: gpg key verification을 스킵(나중에 활성화 필요 할 수 있음)
enabled=1: repository를 활성화
특정 사이트(example.com)를 repo로 사용하라고 하는 경우, baseurl 부분을 아래와 같이 맞춰주면 된다.
baseurl=http://example.com/BaseOS
baseurl=http://example.com/AppStream
dnf clean allvalidation
dnf repolistdnf listOn ServerA, configure the system time to the America/New_York timezone.
answere)
timedatectltimedatectl list-timezones | grep "America/New_York"timedatectl set-timezone "America/New_York"validation
timedatectlOn ServerA, ensure NTP synchronization is configured for accurate timekeeping.
answere)
timedatectlSystem clock synchronized: yes 확인. 아마 no일것임dnf install chrony -ysystemctl enable --now chronydsystemctl status chronydtimedatectl set-ntp true만약 특정 ntp server를 바라보게 해야하는 경우는 아래 풀이를 따른다.
vi /etc/chrony.confserver example.ntp.server.com iburst
iburst: inital burst의 줄임말로, 최초 동기화 시 많은 요청 패킷을 보내는 옵션이다.
systemctl restart chronydchronyc sourcesvalidation
timedatectlSystem clock synchronized: yes 인지 확인On ServerA, use /dev/sdb to do the following:
Create a 2GiB volume group named myvg.
Create a 500MiB logical volume named mylv inside the myvg volume group.
Format the mylv logical volume with the ext4 filesystem and mount it persistently on the /mylv directory.
Extend the ext4 filesystem on mylv by 500MiB.
answere)
fdisk
lsblkfdisk /dev/sdbnp1Enter+2Gt8ewlsblkpvcreate
pvcreate /dev/sdb1pvsCreate VG
vgcreate myvg /dev/sdb1man vgcreate-s ${extent size}: PE(Physical Extent) 크기를 지정해야 할때는, -s 옵션을 쓴다.vgsCreaeting the LV
lvcreate -n mylv -L 500M myvgman lvcreate 활용 하기-n: lv name-L: size-l 100%FREE: vg 백프로 활용하여 lv 생성-l ${extent block number}: PE(Physical Extent)갯수로 size를 지정해야 할때는 -l 옵션을 쓴다.lvsFormat the LV
mkfs.ext4 /dev/myvg/mylvFormat validation
blkid /dev/myvg/mylvMount the LV
mkdir /mylvvi /etc/fstabUUID=${UUID} /mylv ext4 defaults 0 0
mount -alsblkmount validation
df -ThExtend the LV
lvextend -r -L +500M /dev/myvg/mylv-r: resize-L: sizeresize2fs /dev/myvg/mylv 별도 실행LV validation
lvsdf -ThSet up a basic web server on ServerA to display the message Welcome to the webserver! upon connection, while ensuring that the firewall allows HTTP/HTTPS services.
answere)
configure Apache Web server
dnf install httpd -ysystemctl enable --now httpdsystemctl status httpdvi /var/www/html/index.htmlWelcome to the webserver!
ls -Z /var/www/html/index.htmlrestorecon -Rv /var/www/htmlsemanage fcontext -m -t httpd_sys_content_t '/경로(/.*)?'man semanage fcontext-m 부분을 -a로 수정/: 하위 디렉토리 구분자.*: 모든 문자열?: 앞의 그룹(/.*)이 있을수도 있고, 없을수도 있음을 의미restorecon -Rv /경로R: Recursivev: verbosesystemctl restart httpdFirewall to allow http/https traffic
firewall-cmd --list-allfirewall-cmd --add-service=http --permanentfirewall-cmd --add-service=https --permanentfirewall-cmd --reloadfirewall-cmd --list-allvalidation
ss -tnlp | grep httpdcurl http://localhostLocate and copy all files larger than 3MB within the /etc directory on ServerA to a new directory /find/3mfiles.
answere)
mkdir -p /find/3mfilesfind /etc -size +3M -exec cp '{}' /find/3mfiles/ \;man findvalidation
du -sh /find/3mfilesOn ServerA, ensure that boot messages are displayed, not silenced, to aid in troubleshooting.
answere)
vi /etc/default/grubGRUB_CMDLINE_LINUX로 시작하는 줄에서, rhgb quiet만 지운다.find /boot -name grub.cfggrub2-mkconfig -o를 통해 업데이트-o: output filegrub2-mkconfig -o /boot/grub2/grub.cfggrub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfgvalidation
rebootOn ServerA, create a Bash script named /script.sh that outputs the second argument followed by the first argument when executed with two arguments (e.g., "test2 test1" for ./script.sh test1 test2).
answere)
vi /script.sh#!/bin/bash
if [[ $# -ne 2 ]]; then
echo "usage: $0 argument1 argument2" >&2
exit 1
else
echo "$2 $1"
fi
$#: 인자 수
chmod +x /script.shvalidation
/script.sh test1 test2test2 test1
Ensure that a file named Congrats is automatically added to the home folders of all new users created on ServerA.
answere)
touch /etc/skel/Congrats/etc/skel디렉토리는 new user home directory의 template이다.validation
useradd testuserls -al /home/testuserEnforce password expiration after 90 days and a minimum length of 8 characters for all user passwords on ServerA.
answere)
password expiration
vi /etc/login.defsPASS_MAX_DAYS 90
password length
vi /etc/security/pwquality.confminlen=8
validation
useradd testuserpasswd testuserchage -l testuserOn ServerA, create users and groups with specific permissions for directories, ensuring file ownership is correctly set for newly created files.
amr and biko (members of the admins group)carlos and david (members of the developers group)/admins: Accessible only to the owner and admins group members, owned by biko./developers: Accessible only to developers group members, owned by carlos./admins and /developers should inherit the group ownership.answere)
create users and groups
groupadd admins developersuseradd amr bikousermod -aG admins amr bikouseradd carlos davidusermod -aG developers carlos davidcreate and configure directories
mkdir /admins /developersset ownership and permission
chown biko:admins /adminschown carlos:developers /developerschmod 770 /admins /developerschmod g+s /admins /developerschmod +t /admins /developersvalidation
id amr bikoid carlos davidls -ld /admins /developers
On ServerA, configure a cron job that writes the message Get Ready! to the system log file /var/log/messages at noon (12 PM) on weekdays only. Ensure the job is executed with appropriate permissions and logging for troubleshooting.
answere)
which loggerlogger 절대 경로 확인crontab -e0 12 * * 1-5 /usr/bin/logger "Get Ready!"
logger를 이용해 system log(/var/log/messages)에 message를 보낸다.
validation
crontab -ltail -f /var/log/messagesOn ServerA, create a compressed tar archive file named /root/local.tgz that contains the directory /usr/local/ and its contents, ensuring appropriate permissions and verification of the archive.
answere)
tar -cvzf /root/local.tgz /usr/localman tarc: createv: verbosz: gzip, tgzf: file name 지정validation
tar -tvf /root/local.tgzt: listOn ServerA, create a 200MB swap partition using /dev/sdb that automatically activates at boot.
answere)
check current mem
swapon -sCreate partition
fdisk /dev/sdbnpEnterEnter to accept the defaultEnter 2번+200Mpt282pwupdate kernel partition
partprobe /dev/sdbFormat the Partition as Swap
mkswap /dev/sdb2Get the UUID for fstab Configuration
lsblkblkid /dev/sdb2/etc/fstab
vi /etc/fstabUUID=${UUID} none swap defaults 0 0
none: swap으로 마운트 포인트 별도 없음
Activate the Swap Partitoin
swapon -avalidation
free -hswapon -sSet up an SSH passwordless root remote login from ServerA to ServerB.
answere)
On ServerB: ssh server
firewall-cmd --list-allfirewall-cmd --add-service=ssh --permanentfirewall-cmd --reloadfirewall-cmd --list-alldnf install -y openssh-serversystemctl enable --now sshdvi /etc/ssh/sshd_configPermitRootLogin yes
systemctl restart sshdsystemctl status sshdOn ServerA: ssh client
dnf install -y openssh-clientsssh-keygen~/.ssh/id_rsa~/.ssh/id_rsa.pubssh-copy-id root@ServerBssh-copy-id 만 입력하여도 된다.validation
ssh root@ServerBSet the maximum number of SSH login attempts to 2 on ServerA.
answere)
set MaxAuthTries
vi /etc/ssh/sshd_configMaxAuthTries 2
systemctl restart sshdvalidation
ssh testuser@ServerAToo many authentication failures 문구와 함게 실패하는지 확인Configure ServerA to run a container named redis managed by a rootless systemd service.
The service must be declaratively defined using Quadlet.
-> RHCSA 9.0 준비중으로 Quadlet이 아닌 podman을 사용한 풀이 예정
Requirements
systemd service must be generated from a Quadlet file located at ~/.config/containers/systemd/redis.container.ContainerName must be set to redis.docker.io/library/redis image, tagged locally as localhost/myredis.6379 must be mapped to the container's port 6379.redis-data in the user's home directory must be created and used as a persistent volume mounted at /data.Enforcing mode. Resolve any denials by setting the appropriate persistent boolean.answere)
podman
dnf install -y container-toolsfirewall-cmd --add-port=6379/tcp --permanent firewall-cmd --add-service=redis --permanent firewall-cmd --reloadfirewall-cmd --list-allpodman search docker.io/library/redispodman pull docker.io/library/redispodman imagespodman tag docker.io/library/redis localhost/myredispodman imagesmkdir -p ~/redis-datagetenforcesetsebool -P container_manage_cgroup onpodman run
-> podman create(컨테이너 정의) + podman start(컨테이너 시작) 조합
podman run -d
--name redis \
--restart=on-failure \
-p 6379:6379 \
-v ~/redis-data:/data:Z \
localhost/myredis
--name: container name
--restart: restart policy(on-failure: 비정상 종료시, 자동 재시작)
-p ${host_port}:${container_port}: port forwarding
-v ${host_dir}:${container_dir}:Z: 해당 volume을 SELinux 라벨을 설정
localhost/myredis: 사용할 container image 이름
podman pspodman gernerate systemd
cd /etc/systemd/systempodman generate systemd redis --new --files --nameview /etc/systemd/system/container-redis.servicepodman pspodman rm -f redissystemctl daemon-reloadsystemctl enable --now container-redis.servicevalidation
systemctl status container-redis.servicepodman psss -lntp | grep 6379On ServerA, write a script named /users_shells.sh that generates a list of usernames from /etc/passwd along with their login shell.
answere)
vi /users_shells.sh#!/bin/bash
cat /etc/passwd | awk -F: '{print $1 " " $7}'
validation
chmod +x /users_shells.sh/users_shells.shWhat is the default nice level assigned to a process when using the nice command without specifying additional niceness parameters?
answere)
man niceOn ServerA, write a robust and secure shell script named /find.sh that:
filename pattern to search for.regular files inside /home and its subdirectories match the given pattern.No argument is providedMore than one argument is provided/home directory is missingfind command fails during executionanswere)
vi /find.sh#!/bin/bash
if [[ $# -ne 1 ]]; then
echo "Error: Usage: $0 <pattern>. Please provide exactly one argument." >&2
exit 1
fi
if [[ ! -d /home ]]; then
echo "Error: /home directory not found." >&2
exit 1
fi
FIND_FILES=$(find /home -type f -name "$1" 2>/dev/null)
EXIT_CODE=$?
if [[ "$EXIT_CODE" -ne 0 ]]; then
echo "Error: An error occurred during the file search." >&2
exit 1
fi
if [[ -z "$FIND_FILES" ]]; then
echo "Found 0 matching file(s) in /home and its subdirectories."
exit 0
fi
declare -a FILES=()
while IFS= read -r FILE; do
FILES+=("$FILE")
done <<< "$FIND_FILES"
COUNT=${#FILES[@]}
echo "Found $COUNT matching file(s) in /home and its subdirectories."
$#: 인자의 개수
-ne: not equal
>&2: 표준 에러로 출력하겠다는 뜻
exit 1: 스크립트를 비정상 종료
$0: 스크립트 이름
[[ -d /home ]]: home directory가 없는지 확인
[[ ! -d /home ]]: home directory가 없는지 확인
[[ -f /home ]]: home directory가 있는지 확인
[[ ! -f /home ]]: home directory가 없는지 확인
-z: is null
$1: 첫번째 인자
(): 리스트의 원소로서 사용한다는 뜻
2>/dev/null: 에러 메시지를 버림
$?: 직전에 실행한 명령어의 종료 상태
declare -a files=(): array 선언
while IFS= read -r FILE; do: 입력 한 줄을 있는 그대로(공백,탭 보존)읽어서 file 변수에 넣으라는 뜻
${#FILES[@]}: 리스트의 길이
validation
chmod +x /find.sh/find.sh "*.sh"On ServerA, create a versatile and informative shell script named /trim.sh that removes all occurrences of the vowels "a," "i," "e," "o," and "u" from each provided argument. Ensure the script is well-formatted, includes error handling, produces clear output, and follows best practices.
answere)
vi /trim.sh#!/bin/bash
if [[ $# -eq 0 ]]; then
echo "Error: Please provide one or more arguments to trim."
exit 1
fi
while IFS= read -r arg; do
trimmed=$(echo "$arg" | tr -d 'aeiou')
echo "$trimmed"
done <<< "$@"
$#: 인자의 개수
exit 1: 스크립트를 비정상 종료
$(): 괄호 안의 명령어의 결과를 문자열로 치환
$@: 모든 인자들을 개별 인자로 취급
validation
chmod +x /trim.sh/trim.sh "Hello World" "This is a test"Which specific character, when strategically appended to a command, initiates its execution in the background, allowing you to continue interacting with the current shell while the command runs concurrently?
answere)
sleep 30 &&: 백그라운드 명령 실행validation
jobs -lPredict the exact output of the following command, carefully considering the seq command's syntax and behavior:
$ seq 1 5 20
answere)
seq FIRST INCREMENT LASTUsing appropriate commands, create a backup of the Master Boot Record (MBR) located on /dev/sda of ServerA. Store the backup in /backup/mbr.img and ensure it meets the following requirements:
512 bytesanswere)
mkdir -p /backupdd if=/dev/sda bs=512 count=1 of=/backup/mbr.imgman dddd: disk dumpif: input fileof: output filebs: block sizecount: block 갯수status=progress: 진행 상황 실시간 표시 옵션chmod 600 /backup/mbr.imgvalidation
ls -l /backup/mbr.imgIdentify the redirection operator that enables reading input from the current source until a specified separator string, located on a separate line without trailing spaces, is encountered.
answere)
<<cat <<EOF
today date: $(date)
home directory: $HOME
EOF
<<EOF: 지금부터 EOF까지의 내용을 stdin으로 보내라는 뜻
$(): 괄호 안의 명령어의 결과를 문자열로 치환
On ServerA, configure the system to automatically mount the home directories of users Tom and Sam from ServerB using NFS.
The home directories on ServerB are located at /home/tom and /home/sam, with user IDs 1010 and 1020, respectively. The mount should be established in the local /remote_home directory on ServerA, ensuring read and write permissions, efficient resource usage, and seamless user experience.
answere)
1. Configure ServerB as the NFS Server
install nfs services
dnf install -y nfs-utilssystemctl enable --now nfs-server rpcbindsystemctl status nfs-serversystemctl status rpcbindfirewall rules for nfs
firewall-cmd --add-service=nfs --permanentfirewall-cmd --add-service=rpc-bind --permanentfirewall-cmd --add-service=mountd --permanentfirewall-cmd --reloadfirewall-cmd --list-allcreate user Tom and Sam
useradd -u 1010 tomuseradd -u 1020 samu: uid 지정 옵션id tom samconfigure nfs exports
vi /etc/exports/home/tom ServerA(no_root_squash,rw,sync)
/home/sam ServerA(no_root_squash,rw,sync)
rw: read, write
sync: 동기식
no_root_squash: root 사용자 권한 유지
man exports에서 옵션값들에 대해 조금은 참고할수 있다.
apply and verify exports
exportfs -arva: allr: re exportv: verboseshowmount -e2. Configure Autofs on ServerA(NFS Client)
dnf install -y nfs-utils autofsuseradd -M -u 1010 tomuseradd -M -u 1020 samvi /etc/passwdtom:x:1010:1010::/remote_home/tom:/bin/bash
sam:x:1020:1020::/remote_home/sam:/bin/bash
configure autofs for nfs mounting
vi /etc/auto.master/remote_home /etc/auto.home
vi /etc/auto.hometom -fstype=nfs,rw,sync ServerB:/home/tom
sam -fstype=nfs,rw,sync ServerB:/home/sam
systemctl enable --now autofssystemctl status autofsVerification
su - tomdf -Thsu - samdf -ThOn ServerA, as user sam, create a persistent, rootless Apache HTTP web server container using the "registry.redhat.io" registry. Ensure the setup follows best practices for security and efficiency, with these specifications:
httpd-24httpdadmin, Password administrator~/www-data/ on the host to /var/www/html in the containerindex.html file in ~/www-data/ with "Hello World!"8080 to container port 8080HTTPD_USER=test, HTTPD_PASSWORD=testanswere)
root
dnf install -y container-toolsfirewall-cmd --add-port=8080/tcp --permanentfirewall-cmd --reloadgetenforcesetsebool -P container_manage_cgroup onuseradd sam && passwd samloginctl enable-linger samloginctl show-user sampodman
ssh sam@localhost로 유저 전환su - sam로 전환하게 되면, systemctl 명령어 실행시, --user 옵션이 적용되지 않는다.podman login registry.redhat.io -u admin -p administratorpodman search registry.redhat.io/httpd-24podman pull registry.redhat.io/ubi9/httpd-24podman imagespodman tag registry.redhat.io/ubi9/httpd-24 httpd-24podman imagesmkdir ~/www-dataecho "Hello World!" > ~/www-data/index.htmlpodman run
-> podman create(컨테이너 정의) + podman start조합
podman run -d \
--name httpd \
--restart=on-failure \
-p 8080:8080 \
-v ~/www-data:/var/www/html:Z \
-e HTTPD_USER=test \
-e HTTPD_PASSWORD=test \
httpd-24
--name: container name
-p ${host_port}:${container_port}: 포트 포워딩
-v ${host_dir}:${container_dir}:Z: Z는 SELinux 라벨을 부여하는 것
-e: environemt variable
httpd-24: 사용할 container image 이름
podman pscurl 0.0.0.0:8080Hello World! 확인podman gernerate systemd
mkdir -p ~/.config/systemd/usercd ~/.config/systemd/userpodman generate systemd httpd --new --files --nameview ~/.config/systemd/user/container-httpd.servicepodman pspodman rm -f httpdsystemctl --user daemon-reloadsystemctl --user enable --now container-httpd.servicevalidation
systemctl --user status container-httpd.servicepodman psss -lntp | grep 8080curl 0.0.0.0:8080On ServerA, troubleshoot a web server running on port 88 that is unable to serve content correctly. Ensure the following:
/var/www/html are served successfully.88.automatically at system startup.answere)
1) apache 설치 및 활성화 확인
dnf install -y httpdsysetmctl enable --now httpdsystemctl status httpd1) apache 포트 확인
vi /etc/httpd/conf/httpd.confListen 88
systemctl restart httpdss -lntp | grep httpd2) firewall-cmd
firewall-cmd --list-allfirewall-cmd --permanent --add-port=88/tcpfirewall-cmd --reloadfirewall-cmd --list-all3) semanage port
semanage port -l | grep httpsemanage port -m -t http_port_t -p tcp 88-m 부분을 -a로 수정semanage port -l | grep http4) semanage fcontext & restorecon
ls -Z /var/www/html/*httpd_sys_content_t)를 갖고있는지 확인default_t로 변경하고 테스트semanage fcontext -m -t httpd_sys_content_t '/var/www/html(/.*)?'-m 부분을 -a로 수정man semanage fcontext의 EXAMPLE에서 구문 확인 가능(...): 그룹/.*: /다음에 임의의 모든 문자(.*)?: 0회 또는 1회 반복restorecon -Rv /var/www/htmlR: Recursivev: verboseverification
systemctl restart httpdsystemctl status httpdcurl http://localhost:88On ServerA, configure the atd service to allow access for Adam while denying access specifically for Tom. Ensure the configuration aligns with Red Hat’s best practices for security and clarity.
answere)
echo "adam" > /etc/at.allowecho "tom" > /etc/at.denysystemctl restart atdsystemctl enable atdverification
su - adamatsu - tomatYou do not have permission to use at.On ServerA, locate all lines within the /etc/passwd file that include the stringtest. Create a file named /root/test containing exact copies of these lines in their original order, excluding any empty lines.
answere)
grep test /etc/passwd > /root/testgrep -E '^.*test.*$' /etc/passwd > /root/test^: 시작.*: 어떤 것이든$: 끝On ServerA, create a script named /home/XSam.sh that grants the user Sam passwordless sudo access, following security best practices and validating the configuration.
answere)
vi /home/XSam.sh#!/bin/bash
echo "sam ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/sam
chmod 440 /etc/sudoers.d/sam
sudo -u sam sudo -n true
if [[ $? -eq 0 ]]; then
echo "Success"
else
echo "Error"
exit 1
fi
sudo -u sam: sam 사용자로 이 다음 명령을 실행하라는 뜻
sudo -n true:sudo 동작이 가능한지 테스트용으로 흔히 쓰임
$?: 직전에 실행한 명령어의 종료 상태
0: 성공(정상 종료)
1: 실패(비정상 종료)
validation
chmod +x /home/XSam.sh./Xsam.shOn ServerA, create a compressed archive of the /usr/local/bin/ directory using tar with bzip2 compression. Exclude Git directories, as they can be large and are unnecessary for backups. Store the archive in /home with the filename local-bin.tar.bz2. Finally, verify the contents of the archive.
answere)
dnf install -y bzip2tar -cvjf /home/local-bin.tar.bz2 --exclude="*/.git/*" /usr/local/bin/man tarc: createv: verbosj: bzip2f: filevalidation
tar -tvf /home/local-bin.tar.bz2 | grep gitt: listv: verbosf: fileOn ServerA, append the message Ended on $(date) by $LOGNAME to the /var/log/messages file with root privileges, using the tag my_script for the log message. Then, verify that the message was added by using regular expressions.
answere)
logger -t "my_script" "Ended on $(date) by $LOGNAME"t: tag$(): 괄호 안의 명령어의 결과를 문자열로 치환validation
grep "my_script" /var/log/messagesConfigure ServerA to automatically boot into the multi-user.target, ensuring a non-graphical, multi-user environment for command-line administration.
answer)
systemctl get-defaultsystemctl set-default multi-user.targetvalidation
systemctl get-defaultrebootll /etc/systemd/system/default.targetOn ServerA, create a new user named Samir and grant him the ability to execute commands with root privileges using sudo. Ensure clarity, conciseness, and accuracy, and consider alternative approaches.
answer)
useradd Samirpasswd SamirvisudoSamir ALL=(ALL) ALL
validation
sudo -u Samir sudo -n trueAs user samir, securely transfer the sensitive file /etc/hosts from ServerA to the /home/samir_dir/ directory on ServerB, ensuring confidentiality and integrity during transit. Choose a secure transfer method appropriate for Red Hat Enterprise Linux (RHEL) 9.
Note:
samir must have a dedicated directory (/home/samir_dir/) on ServerB with appropriate permissions.answer)
ServerB
useradd samirpsaswd samirssh-copy-id 실행시, ServerB samir의 비밀번호 필요mkdir -p /home/samir_dirchown samir:samir /home/samir_dirchmod 700 /home/samir_dirfirewall-cmd --list-allfirewall-cmd --add-service=ssh --permanentfirewall-cmd --reloadfirewall-cmd --list-alldnf install -y openssh-serversystemctl enable --now sshdsystemctl status sshdOn ServerA: ssh client
dnf install -y openssh-clientsssh-keygen~/.ssh/id_rsa~/.ssh/id_rsa.pubssh-copy-id samir@ServerBssh-copy-id 만 입력하여도 된다.validation
sftp samir@ServerBsftp> put /etc/hosts /home/samir_dirsftp> ls /home/samir_dirsftp> exitYou are the administrator for two Red Hat Enterprise Linux (RHEL) 9 servers, ServerA and ServerB. ServerB runs the Apache HTTP Server and needs access to files in /var/www/html/mydirectory, but SELinux is currently blocking this access. Modify the SELinux policy on ServerB to allow Apache to access these files securely, following best practices.
Additional Considerations:
1. Ensure the modification persists after a reboot.
2. Minimize impact on other applications or directories.
answer)
getenforcels -Z /var/www/html/mydirectoryhttpd_sys_content_t 설정되어있는지 확인default_t or var_t 등의 다른 라벨이면 apache가 접근 불가능semanage fcontext
semanage fcontext -m -t httpd_sys_content_t '/var/www/html/mydirectory(/.*)?'-m 부분을 -a로 수정man semanage fcontext의 EXAMPLE에서 구문 확인 가능(...): 그룹/.*: /다음에 임의의 모든 문자(.*)?: 0회 또는 1회 반복restorecon
restorecon -Rv /var/www/html/mydirectoryR: Recursivev: verbosels -Z /var/www/html/mydirectoryvalidation
echo "hello, world!" > /var/www/html/mydirectory/test.htmlcurl http://localhost/mydirectory/test.html