리눅스 서버에 허용된 클라이언트에 대해 원격 로그인, 원격 쉘명령을 내릴 수 있는 rlogin과 rsh 구성에 대해 알아본다.
목차
1. 서버
1.1. 서버 정보
RHEL 6.4 x86_64
IP : 192.168.0.51
1.2. 패키지 설치
[root@rsh-Server ~]# yum install -y rsh-server
참고
RHEL 6.x 부터는 기본적으로 OS설치 시 xinetd 패키지가 빠져서 설치된다.
rsh-server는 xinetd에 종속된 서비스 이기 때문에 xinetd가 없으면 yum으로 설치 시 함께 설치된다.
1.3. 시작서비스 등록
RunLevel 3, 5에 대해서 부팅시 자동시작될 수 있도록 등록
[root@rsh-Server ~]# chkconfig --level 35 rsh on [root@rsh-Server ~]# chkconfig --level 35 rlogin on
1.4. xinetd 설정 확인
[root@rsh-Server ~]# cat /etc/xinetd.d/{rsh,rlogin} | grep disable disable = no disable = no
참고
만약 중지하고 싶은 서비스가 있으면 아래 두개의 파일을 disable = yes 로 수정하고 xinetd를 restart 합니다.
/etc/xinedt.d/rsh
/etc/xinedt.d/rlogin
1.5. tty 접근 제어
맨 아래에 두줄을 추가 한다.
[root@rsh-Server ~]# vim securetty . . rsh rlogin
참고
만약 rlogin을 빼면 client에서 접근 시 패스워드를 묻고,
rsh로 접근 시에는 Permission denied. 메시지와 함께 접근이 안된다.
1.6. pam 설정
비밀번호 없이 접근 제어를 하기 위해서 pam 설정을 수정한다.
/etc/pam.d/rsh와 /etc/pam.d/rlogin에 대해 아래처럼 수정한다. 위 4줄을 required -> sufficient 변경
[root@rsh-Server ~]# vim /etc/pam.d/rlogin auth sufficient pam_nologin.so auth sufficient pam_securetty.so auth sufficient pam_env.so auth sufficient pam_rhosts.so auth include password-auth account include password-auth password include password-auth session optional pam_keyinit.so force revoke session required pam_loginuid.so session include password-auth
1.7. xinetd 재가동
[root@rsh-Server ~]# /etc/init.d/xinetd restart
1.8. 서비스 확인
[root@rsh-Server ~]# netstat -lnpt | grep xinetd tcp 0 0 :::513 :::* LISTEN 39307/xinetd tcp 0 0 :::514 :::* LISTEN 39307/xinetd
tcp 513 port : rlogin 참고
tcp 514 port : rsh
1.9. TCPWrapper 적용
1) 허용 룰
허용할 서비스별로 호스트들의 IP또는 IP 대역을 입력한다.
[root@rsh-Server ~]# vi /etc/hosts.allow in.rshd:\ 192.168.0.71 \ 192.168.0.81 \ 192.168.0.91 in.rlogind:\ 192.168.0.71 \ 192.168.0.81 \ 192.168.0.91 sshd:\ 192.168.0.71 \ 192.168.0.81 \ 192.168.0.91
2) 차단 룰
TCPWrapper에 적용받는 모든 서비스에 대해서 차단한다.(단, hosts.allow의 설정값은 예외)
[root@rsh-Server ~]# vi /etc/hosts.deny ALL : ALL
2. 클라이언트
2.1. 클라이언트 정보
OS : RHEL 6.4 x86_64
IP : 192.168.0.71
2.2. 패키지 설치
[root@rsh-Client ~]# yum install -y rsh
2.3. 접근 테스트
1) rsh
[root@rsh-Client ~]# rsh 192.168.0.51 touch /root/test [root@rsh-Client ~]# rsh 192.168.0.51 ls -la /root/test -rw-r--r-- 1 root root 0 2014-10-15 17:42 /root/test
2) rlogin
[root@rsh-Client ~]# rlogin -l root 192.168.0.51 Last login: Wed Oct 15 17:35:17 from 192.168.0.71 [root@rsh-Server ~]# ls -la /root/test -rw-r--r-- 1 root root 0 2014-10-15 17:42 /root/test
rlogin으로 서버에 접속하여 확인해 봐도 /root/test 파일이 생성된 것을 볼 수 있다.
이상으로 문서를 마친다.