Oracle® Solaris 11.2의 보안 셸 액세스 관리

인쇄 보기 종료

업데이트 날짜: 2014년 9월
 
 

sftp 파일에 대한 격리된 디렉토리를 만드는 방법

이 절차에서는 특히 sftp 전송을 위해 만들어진 sftponly 디렉토리를 구성합니다. 사용자는 전송 디렉토리 외부의 파일 또는 디렉토리를 볼 수 없습니다.

시작하기 전에

root 역할을 맡아야 합니다. 자세한 내용은 Oracle Solaris 11.2의 사용자 및 프로세스 보안 의 지정된 관리 권한 사용을 참조하십시오.

  1. 보안 셸 서버에서 격리된 디렉토리를 chroot 환경으로 만듭니다.
    # groupadd sftp
    # useradd -m -G sftp -s /bin/false sftponly
    # chown root:root /export/home/sftponly
    # mkdir /export/home/sftponly/WWW
    # chown sftponly:staff /export/home/sftponly/WWW

    이 구성에서 /export/home/sftonlyroot 계정만 액세스할 수 있는 chroot 디렉토리입니다. 사용자에게 sftponly/WWW 하위 디렉토리에 대한 쓰기 권한이 있습니다.

  2. 계속해서 서버에서 sftp 그룹에 대한 Match 블록을 구성합니다.

    /etc/ssh/sshd_config 파일에서 sftp subsystem 항목을 찾고 파일을 다음과 같이 수정합니다.

    # pfedit /etc/ssh/sshd_config
    ...
    # sftp subsystem
    #Subsystem       sftp    /usr/lib/ssh/sftp-server
    Subsystem       sftp    internal-sftp
    ...
    ## Match Group for Subsystem
    ## At end of file, to follow all global options
    Match Group sftp
    ChrootDirectory %h
    ForceCommand internal-sftp
    AllowTcpForwarding no

      다음 변수를 사용하여 chroot 경로를 지정할 수 있습니다.

    • %h – 홈 디렉토리를 지정합니다.

    • %u – 인증된 사용자의 사용자 이름을 지정합니다.

    • %% - % 기호를 이스케이프 처리합니다.

  3. 클라이언트에서 구성이 올바르게 작동하는지 확인합니다.

    chroot 환경의 파일이 다를 수 있습니다.

    root@client:~# ssh sftponly@server
    This service allows sftp connections only.
    Connection to server closed. No shell access, sftp is enforced.
    root@client:~# sftp sftponly@server
    sftp> pwd sftp access granted
    Remote working directory: /chroot directory looks like root directory
    sftp> ls
    WWW             local.cshrc     local.login     local.profile
    sftp> get local.cshrc
    Fetching /local.cshrc to local.cshrc
    /local.cshrc    100%  166     0.2KB/s   00:00user can read contents
    sftp> put /etc/motd
    Uploading /etc/motd to /motd
    Couldn't get handle: Permission denieduser cannot write to / directory
    sftp> cd WWW
    sftp> put /etc/motd
    Uploading /etc/motd to /WWW/motd
    /etc/motd     100%  118     0.1KB/s   00:00user can write to WWW directory
    sftp> ls -l
    -rw-r--r--    1 101  10    118 Jul 20 09:07 motdsuccessful transfer
    sftp>