jailedshell
Enable or disable a restricted, chrooted SSH shell for an account (bash, ls, cat, rm, and mkdir only)
- Command:
/go/jailedshell - Category: Accounts
- Required arguments:
<domain> - Optional argument:
0or--disableto turn the jailed shell off - Output: The output of the system commands it runs, then of
ssh - Last updated: 2026-11-19
On this page: Overview · Quick start · Syntax · Arguments · Output · What the jail contains · Examples · Troubleshooting · Details · See also
Overview
/go/jailedshell gives an account an SSH shell that is confined to its own home folder (a chroot jail). Inside the jail the user sees /home/<domain> as /, and can only run a handful of commands. It:
- adds the account's user to a group named
Jailed - makes
/home/<domain>owned byroot, as a chroot requires - builds a small root file system inside the home folder with
bash,ls,cat,rm, andmkdirand the libraries they need - marks the account as having a jailed shell, and turns off the account's normal shell
- runs
sshto apply the SSH server configuration
The restriction is enforced by the SSH server. It works only if the configuration written by ssh contains the chroot rule for the Jailed group.
Quick start
# Enable the jailed shell
/go/jailedshell example.com
# Disable it
/go/jailedshell example.com --disable
Syntax
/go/jailedshell <domain>
/go/jailedshell <domain> 0
/go/jailedshell <domain> --disable
| Form | Behavior |
|---|---|
/go/jailedshell <domain> |
Enables the jailed shell. |
/go/jailedshell <domain> 0 |
Disables it. |
/go/jailedshell <domain> --disable |
Disables it. --disable can be anywhere in the arguments. |
[!WARNING] Only
0and--disableturn the jail off. Any other value enables it, including the worddisable.
[!WARNING] Always pass the domain. With an empty domain the commands work on
/homeitself and leave stray folders and files there.
Arguments
| Argument | Required | Default | Notes |
|---|---|---|---|
<domain> |
Yes | — | The account's primary domain, as stored in GoAdmio. It is not checked. |
0 or --disable |
No | Enable | Disables the jailed shell. |
Output
The command prints no messages of its own. You see the output of the programs it runs:
| Output | Meaning |
|---|---|
groupadd: group 'Jailed' already exists |
Harmless. The group is created again on every run. |
Removing user <name> from group Jailed |
Printed when disabling. |
cp: ... errors |
A library or program could not be copied. |
The output of ssh |
The SSH configuration was rewritten. |
The exit code is the one returned by ssh.
Logging
Every run is appended to /var/log/go/jailedshell.log.
What the jail contains
| Path inside the jail | Content |
|---|---|
/bin |
bash, ls, cat, rm, mkdir |
/lib, /lib64 |
The libraries of those programs |
/etc/profile, /etc/bashrc |
Shell settings that set PATH |
/.bash_profile, /.bashrc |
The user's start-up files |
| The account's own folders | www, mail, sqlite, and so on |
There is no editor, no cp, mv, chmod, tar, php, or mysql. In practice the user can list, read, delete, and create folders. For file transfers they use SFTP or the File Manager.
The files in the jail are copies. Security updates of bash and the system libraries don't reach them. Run the command again to refresh the copies.
Examples
# Enable for one account
/go/jailedshell example.com
# Disable
/go/jailedshell example.com --disable
# Check the group and the jail
getent group Jailed
ls /home/example.com/bin
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
/go/jailedshell example.com disable turned the jail on |
Only 0 and --disable disable it. |
Use --disable. |
sudo: command not found at every login |
The start-up files in the jail call sudo test -f, and there is no sudo inside the jail. |
See Notes for maintainers. |
The user can't edit or copy files, or run php or mysql |
The jail has only five commands. | Use SFTP or the File Manager, or give the account a normal shell with shell. |
SSH login fails with bad ownership or modes for chroot directory |
/home/<domain> isn't owned by root, or is writable by others. |
Run /go/jailedshell <domain> again, or fix. |
| SSH login connects and closes at once | The SSH server isn't set up for the Jailed group, or the shell or its libraries are missing in the jail. |
Run ssh, and check /home/<domain>/bin and lib. |
| File owners show as numbers | The jail has no passwd and group files. |
Run passwd for the domain. |
Some commands print /dev/null: No such file or directory |
The jail has no device files. | See Notes for maintainers. |
The account has no shell after --disable |
The account's normal shell was turned off when the jail was enabled, and disabling doesn't turn it on again. | Enable it with shell. |
The jail's folders remain after --disable |
The command doesn't delete them. | Remove them by hand if needed. |
A stray folder appeared in /home, or files appeared in /home itself |
A typo in the domain, or no domain. | Delete the stray folder, and check /home/bin, /home/lib, /home/etc. |
The jail's bash is old |
The copies aren't updated. | Run the command again after system updates. |
Details
What it does
- Logs the call, and looks up the account's username.
- Disable (
0, or--disableanywhere): removes the user from theJailedgroup and setsJailedShellto0in the panel. - Enable (everything else):
- Creates the
Jailedgroup, and adds the user to it. - Makes
/home/<domain>owned byroot:rootwith mode755. - Creates
bin,lib,lib64, andetcinside it, and copies/bin/bashintobin. - Writes
etc/profile,etc/bashrc,.bash_profile, and.bashrc. - Finds the libraries of
bashwithlddand copies them into the jail, keeping their paths. - Copies
ls,cat,rm, andmkdirwith their libraries. - Sets
JailedShellto1andShellto0in the panel.
- Creates the
- Runs
sshin both cases.
flowchart TD
A["jailedshell domain action"] --> B{"0 or --disable?"}
B -- "Yes" --> C["Remove user from Jailed group, JailedShell = 0"]
B -- "No" --> D["Add user to Jailed group, root-own home"]
D --> E["Copy bash, ls, cat, rm, mkdir and libraries"]
E --> F["JailedShell = 1, Shell = 0"]
C --> G["Run ssh"]
F --> G
Notes for maintainers
| Issue | Why it matters | Suggested fix |
|---|---|---|
.bash_profile and .bashrc in the jail use sudo test -f |
There is no sudo inside the jail, so the test fails, sudo: command not found is printed, and the profile files are never loaded. |
Use [ -f /etc/profile ] (a shell built-in). |
| No check of the arguments | An empty domain makes the script work on /home itself (/home/bin, /home/lib, /home/etc, and a changed mode on /home). A typo creates a stray folder. |
Exit unless the domain is in the Site table and /home/<domain>/www exists. |
Only 0 and --disable disable, and anything else enables |
disable or a typo turns the jail on. |
Accept disable and off too, and print usage for unknown values. |
Disabling leaves the jail files, doesn't turn Shell back on, and doesn't remove the group |
The account ends up with no shell at all. | Restore the previous Shell value, and clean up. |
The jail holds copies of bash and the libraries |
Updates don't reach them, so every jail keeps old, possibly vulnerable files. | Refresh the copies after system updates, or use read-only bind mounts. |
| Only five commands | No editor, cp, mv, or chmod, so the shell is of little use. |
Make the list configurable. |
No /dev nodes and no /etc/passwd or /etc/group are created |
The OpenSSH manual says an interactive chroot session needs basic device files such as null and tty. Names show as numbers unless passwd copies the user entries. |
Create the device nodes, and call passwd <domain> at the end. |
chmod 755 /home/<domain> here, 711 in fix |
The mode flips between the two commands. | Pick one. |
The ldd pattern only matches paths that contain /lib/ or /lib64/ |
A library elsewhere is missed. | Parse the => column of ldd and add the dynamic loader. |
groupadd Jailed runs every time |
An error message on every run after the first. | Use getent group Jailed || groupadd Jailed. |
The jail depends on ssh writing the chroot rule |
If the rule is missing, group membership alone doesn't confine the user. | Check for the rule at the end, and warn if it is missing. |
ssh runs even when earlier steps failed |
A half-built jail is applied. | Stop on the first error. |
| The domain is placed directly in SQL and in paths | A quote or .. breaks the command. |
Validate against ^[a-z0-9.-]+$. |
See also
| Command | Description |
|---|---|
shell |
Enable or disable SSH shell access for an account |
ssh |
Rewrite /etc/ssh/sshd_config with GoAdmio hardening |
passwd |
Refresh an account's user and group entries in its site etc folder |
fix |
Fix GoAdmio file and folder permissions |
ftp |
Create or edit FTP accounts for a domain |
port |
Change the default SSH port (22) to another port |
permitrootlogin |
Allow root SSH login from a specific IP |