IT 이야기 - About IT

[HP-UX] User Group을 이용한 FTP 디렉토리 접근 제어

회사원 주씨 2009. 7. 15. 08:50
반응형


특별한 설정없이 ftp를 통해 특정 user가 접근하게 되면
당연 상위디렉토리까지 접근이 가능하다.
물론 파일에 대한 접근권한이 없는 경우는 무용지물이긴 하지만,
업무특성상 같은 그룹에 속해있는 다른 사용자들끼리는 파일을 공유 할 수 있기때문에
보호해야할 파일이 있을 경우 난감할 수 있다.

해결방법은 ftp로 접속한 유저가 자신의 홈디렉토리보다 상위에 있는 디렉토리로
이동하지 못하도록 하는게 가장 쉬운방법이며, 아래의 내용을 참고하자.

예제는 ftpguest라는 user를 예를 들어설명하였고 해당 user의 group은 ftpgroup인 상태이다.

1. /etc/passwd 파일 수정
> vi /etc/passwd
ftpguest:4rL2HZkDatENY:505:125::/home/ftpguest/./:/usr/bin/sh                                                                                  
                  homedir다음에 나오는 /./ 부분이 pwd했을 때 /로 나오게 해서 다른 folder로 접근을 막아주게 하는 처리입니다.
 
2. /etc/shells 에 /usr/bin/sh 가 있는지 확인하시고, /etc/shells 파일이 없을때는 무시

3. /etc/group 파일 수정
> vi /etc/group
ftpgroup::125:ftpguest

tip. Create and set the permissions and ownership for the directory
(/home/ftp/ftpguest) to what suits you best.

4. /etc/ftpd/ftpaccess 파일 수정
tip. 파일이 없을 경우 아래의 방법으로 복사해서 사용하면 된다.
      > cp /usr/newconfig/etc/ftpd/examples/ftpaccess /etc/ftpd/ftpaccess

> vi /etc/ftpd/ftpaccess
# specify which group of users will be treated as "guests".
guestgroup ftpgroup
################################################################
class   all   real,guest,anonymous  *
# limit   all   10   Any              /etc/msgs/msg.dead

readme  README*    login
readme  README*    cwd=*

# message /welcome.msg            login
# message .message                cwd=*

compress        yes             all
tar             yes             all

# log commands real,guest
# log transfers anonymous,real,guest inbound,outbound
# log syslog+xferlog
# shutdown /etc/shutmsg
# email user@hostname
# specify which group of users will be treated as "guests".
guestgroup ftpusr2
################################################################

5. /etc/inetd.conf 파일 수정 및 관련 프로세스 재시작

> vi /etc/inetd.conf  ==> '-a' option 옵션 추가
use the ftpaccess file. Here is an example;
ftp          stream tcp nowait root /usr/lbin/ftpd      ftpd -l -a

> /usr/sbin/inetd -c

6. 상위디렉토리로 이동하지 못하게 함으로써 /usr/bin/ls 명령어가 실행이 안되는 것으로 인해
ls가 가능하도록 해주는 작업입니다.

> cd /home/ftpguest    (해당 homedir로 이동)
> mkdir usr
> mkdir usr/bin
> chown -R bin:bin usr
> chown -R root:bin usr/bin
> chmod 555 usr
> cp -p /sbin/ls usr/bin/ls
 

7. /etc/ftpd/ftpgroups 파일 생성

> touch /etc/ftpd/ftpgroups

tip.
Another thing I noticed is that you must touch the file /etc/ftpd/ftpgroups.
If you do not, you will see messages in syslog.log indicating that ftpd could
not stat this file.

728x90