Use openssh to implement chroot prison monitoring

Source: Internet
Author: User
Using openssh to implement chroot to secure users who do not want to log on via SSH to browse the files in our system at will and only fix the activities in specified places. Environment: RedHatEnterpriseLinuxServerrelease6.2openssh requires a version 4.7p or later to create a version that allows ssh...
Using openssh to implement chroot to secure users who do not want to log on via SSH to browse the files in our system at will and only fix the activities in specified places. Environment: Red Hat Enterprise Linux Server release 6.2 openssh requires versions later than 4.7 p to create a login user that allows ssh [root @ localhost ~] # Useradd gao change the user's password www.2cto.com [root @ localhost ~] # Passwd gaoChanging password for user gao. New password: Retype new password: passwd: all authentication tokens updated successfully. create the chroot Directory [root @ localhost ~] # Switch mkdir/vm/chroot to the created directory, create the directory structure [root @ localhost chroot] # mdkir bin home lib64 to copy the master directory of the gao user to the created home [root @ localhost chroot] # cp-r /home/gao // vm/chroot/home/copy the executable program and log on to bash, refer to copy the execution script 123.sh [root @ localhost chroot] # cd bin/[root @ localhost bin] # cat 123.sh #! /Bin/bashcmd = "bash touch more less awk sed vim mkdir" for I in $ Export do a = 'which $ I 'cp $. the/done command can add www.2cto.com and copy the dependent files. for details, refer to copy the dependent file script 456.sh [root @ localhost bin] # cd .. /lib64/[root @ localhost lib64] # cat 456.sh #! /Bin/bashcmd = "touch more less awk sed vim mkdir" for I in $ unlock do ldd 'which $ I '| awk' {print $3} '| while read; do cp $. /; after all the copies of donedone are completed, modify the ssh configuration file www.2cto.com [root @ localhost lib64] # vim/etc/ssh/sshd_config and add Match User gaoChrootDirectory/vm/chroot to restart the SSH service [root @ localhost lib64] #/etc/init. d/sshd restart use another machine to log in and test www.2cto.com [root @ perl ~] # Ssh gao@10.1.100.103gao @ 10.1.100.103's password: Last login: wed Oct 10 11:54:00 2012 from 10.1.100.104-bash-4.1 $ cd/-bash-4.1 $ pwd/-bash-4.1 $ lsbin home lib64-bash-4.1 $ simple chroot has been completed
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.