Linux_p #11
관리자적 명령어들
1. root 의 패스워드 변경하기
centos1 시작화면에서 i - e
2. 부팅 정보를 가지고 있는 /etc/grub.conf 파일 잠궈두기
# ls -l /etc/grub2.cfg
# vi /boot/grub2/grub.cfg &
# grub2-setpassword
# cat /boot/grub2/user.cfg
# grub2-mkconfig -o /boot/grub2/grub.cfg
reboot
시작화면시 i - e
Enter username:
root
rootoor
3. chroot(change root)
관리자는 서버 시스템에 FTP나 ,HTTP, NFS 등의 서버 서비스를 설정해두고, 클라이언트들이 FTP나 Telnet, SSH, HTTP 등으로 서버에 연결해서 파일을 업/다운로드하게 하는데 FTP 서버인 경우 FTP 서버의 오픈 디렉터리 /var/ftpd/pub 디렉터리, HTTP인 경우 /var/www/html 디렉터리로 들어와서 cd ../나 ls ../ 해서 오픈된 pub 디렉터리의 상위 디렉터리로 이동하거나 살펴보게 하면 보안상 문제가 될 수 있다.
이럴 때 chroot를 사용하는데 이 명령어는 어느 디렉터리를 가상의 최상위 / 디렉터리로 만들어서 cd ../ 했을 때 더 이상 상위 디렉터리로 이동하지 못하게 해서 보안을 증진시킨다.
SSH 서비스가 있다는 것은 SSL로 이미 키를 사용해서 연결한다는 의미이다.
=>SSL(Secure Socket Layer)로 sftp, https, smtps, ... 등이 가능한 것이다.
# service sshd restart
# netstat -nltp |grep 22
--ubuntu
& sftp centos@192.168.100.129
pwd && ls
ls
cd etc
pwd
get passwd
!ls
!head -1 passwd
--centos1
# vi /etc/ssh/sshd_config
--ubuntu
pwd
cd ..
pwd
ls
cd /secure
cd /ftp
mkdir tester1
ls /ftp
--centos1
# ls /secure/tester/ftp
4. chcon (change context)과 restorecon
# getsebool -a | grep ftp_home_dir
# firewall-cmd --permanent --add-port=80/tcp --zone=public
# firewall-cmd --reload
# yum -y install httpd httpd-manual
# cat -n /etc/httpd/conf/httpd.conf
->353줄에 IncludeOptional conf.d/*.conf
->메인 설정 파일은 여기 있는데
# getenforce
->Enforcing
# cp -arp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak (파일 백업)
# nano /etc/httpd/conf/httpd.conf
->95줄 #ServerName 주석 제거 -> 192.168.100.129:80
->353 Include~ 확인
# nano /etc/httpd/conf.d/web.conf
Alias /web /web/
<Directory /web>
Options Indexes
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
# apachectl configtest
# chmod 777 /web/index.html
# cat -n /etc/httpd/conf/httpd.conf
# service httpd restart
# echo "<h1>This is main Web page</h1>" > /var/www/html/index.html
# mkdir /web
# echo "<h2>This is Sub Web page</h2>" > /web/index.html
# chmod 777 /web/index.html
--bt
firefox http://192.168.100.143
->Forbidden
--centos1
# ls -dZ /web
# ls -dZ /var/www/html
# chcon -Rv --type=httpd_sys_content_t /web
# chcon --reference=/var/www/html/index.html /web/index.html
# ls -dZ /web/index.html
# restorecon -R /web/
# ls -dZ /web/