Git Product home page Git Product logo

ssh_chrootjail's Introduction

SSH Chroot jail setup script

Sets up ssh jail automatically. Warning: After launching the script do not forget to edit your sshd config file to add the ChrootDirectory option

Example:

Match User guest

Chroot Directory /jail/guest/

Match all


 

After the configuration restart the ssh server on systemd by typing sudo systemctl restart sshd

This allow user guest to be run only in the chroot environment Additionally it is possible to allow the sftp command by changing Subsystem to Subsystem sftp internal-sftp

Configuration


  CFG_USERNAME Name of the user that will be locked in the chroot environment

  CFG_USERSHELL A default shell that the user can access in chroot (need to specify full path)

  CFG_JAILDIR A directory where user will be chrooted

  CFG_HOME_PERMISSION Access to the chroot directory (default 700, only the created user can access the directory)

  CFG_DEFAULT_PROGS A list of programs separated by a whitespace that the user can access. To add more programs please refer to the addtojail.sh documentation
 

Adding programs to the jail

run the addtojail.sh script. The first argument is the path to the jail directory. All of the other arguments are the names of the programs which will be added. The program needs to be in the PATH variable

Installation (Linux)

cd path_to_the_folder
chmod +x sshjail_setup.sh
chmod +x addtojail.sh

Uninstallation

Remove the chroot directory eg. sudo rm -rf /jail Delete the user and his home directory sudo userdel guest Optionally the guests home directory can be removed. Make sure to backup all important files and run sudo rm -rf /home/guest`

Tested platform

Arch Linux: linux-6.0.12-zen1-1-zen, Openssh 9

ssh_chrootjail's People

Contributors

shadowdevz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.