원문 : http://www.ischo.net -- 조인상 //시스템 엔지니어

+++++++++++++++++++++++++++++++++++++++++++++++++++++++



참고 : https://support.hpe.com/hpsc/doc/public/display?docId=emr_na-c01516983



목표 : HP-UX 환경에서 sftpuser 계정으로 ssh 접속은 불허용, sftp접속만 가능하도록 구성



1. 디렉토리 생성

# mkdir -m 755 /sftpdir


2. 계정생성

# useradd -d /sftpdir/home/sftpuser -s /bin/sh sftpuser


3. /opt/ssh/utils/ssh_chroot_setup.sh 실행

# /opt/ssh/utils/ssh_chroot_setup.sh

         HP SECURE SHELL: CHROOT ENVIRONMENT SETUP - MAIN MENU
         -----------------------------------------------------

         Select one of the option below

         1.Configure a new user

         2.Configure an existing user to a chroot-ed user

         3.Remove chroot environment from a chroot-ed user

         4.Exit


         Enter your choice : 2

         Chroot setup
        ---------------

         User name (Maximum eight chars) : sftpuser

         chroot setup checks for user details ...completed


         Enter the new root directory for sftptest with absolute path (or press return for default(/newroot)): /sftpdir


         ---------------------------------
         Select chroot secure shell option
         ----------------------------------
         1 sftp
         2 ssh & sftp & scp
         press return key to skip this step


         Option : 1

         chroot setup for sftp operations

         IMPORTANT NOTE:
         This setup will make sure that sftp works in your chroot environment
         It should not be interpreted as a restrictive sftp-only Shell.
         This setup simply copies the files required for sftp to the appropriate directories under the newroot.


         Now configuring the chroot environment for sftp ...finished

         Summary
         --------

         Chroot-ed user : sftpuser

         Chroot-ed user's new root directory : /sftpdir/home/sftpuser

         Secure Shell configuration : SFTP

         press Return key


         HP SECURE SHELL: CHROOT ENVIRONMENT SETUP - MAIN MENU
         -----------------------------------------------------

         Select one of the option below

         1.Configure a new user

         2.Configure an existing user to a chroot-ed user

         3.Remove chroot environment from a chroot-ed user

         4.Exit


         Enter your choice : 4



4. chroot 된 디렉토리 환경설정

# chmod 777 /sftpdir/tmp

# chown sftpuser /sftpdir/home/sftpuser

# cp -p /var/adm/wtmp /sftpdir/var/adm



5. chroot된 디렉토리내 sh 삭제

# rm /sftpdir/bin/sh



6. ssh 접속테스트


7. sftp 접속 및 업로드, 파일 삭제 테스트