ENDEBook a demo
← Back to all tasks

Ubuntu

Please create an SSH user named "charles" with password "Ex@mpleP@55w0rd!" on Ubuntu who is only allowed to access the folder "/home/test1".

Result
Solved
Points
1 / 1
Steps
8
Duration
6 min 31 s

Evaluation criteria

  • Checks that the result contains every required piece of text and none of the forbidden ones.
View the task definition in the OSWorld repository

Final response

Done. Created SSH user 'charles' (password Ex@mpleP@55w0rd!) with home /home/test1 and shell /bin/bash. Configured /etc/ssh/sshd_config with a 'Match User charles' block that chroots them to /home/test1 via ChrootDirectory and forces internal-sftp (ForceCommand), and set /home/test1 to root:root mode 755 as sshd requires. Installed openssh-server and validated the config with 'sshd -t' (no errors). The user is now confined to /home/test1 over SSH/SFTP.

Trajectory

  1. Step 10:01

    The goal is a system-admin task: create an SSH user 'charles' (password Ex@mpleP@55w0rd!) confined to /home/test1. I have a directly relevant KB memory that documents the exact recipe for this computer: give the folder as the user's home (useradd -m -d /home/test1 -s /bin/bash charles), set the password, then add a `Match User charles` block to /etc/ssh/sshd_config with `ChrootDirectory /home/test1` and `ForceCommand internal-sftp`, and make the chroot folder root-owned 755 (chown root:root, chmod 755). Verify with getent passwd, stat, and sudo sshd -t. No terminal window is open, so I'll use my shell tool with `echo password | sudo -S ...`. I'll draft a 3-subgoal plan and commit it.

    • Plan created
      1. Create user 'charles' with home /home/test1 and a login shell, and set its password to Ex@mpleP@55w0rd!
      2. Configure SSH to chroot 'charles' to /home/test1 (internal-sftp) and set the chroot folder ownership/permissions (root:root, 755)
      3. Verify the SSH configuration is valid and sshd is available
    • Plan confirmed3 subgoals
  2. Step 21:15

    Starting subgoal 1: create user 'charles' with home /home/test1 and login shell /bin/bash, then set the password. I'll use the shell tool with sudo (password: 'password' from KB).

    • Shell commandecho password | sudo -S useradd -m -d /home/test1 -s /bin/bash charles && echo 'charles:Ex@mpleP@55w0rd!' | sudo -S chpasswd && getent passwd charles
    • In progressCreate user 'charles' with home /home/test1 and a login shell, and set its password to Ex@mpleP@55w0rd!
  3. Step 31:37

    Mark sg-1 done, start sg-2. Append a 'Match User charles' block to /etc/ssh/sshd_config with ChrootDirectory /home/test1 and ForceCommand internal-sftp, and set /home/test1 to root:root mode 755 (required for sshd chroot). I'll do this in one shell command and verify the file tail plus stat.

    • Subgoal completedUser charles created with home /home/test1, shell /bin/bash, password set.
    • In progressConfigure SSH to chroot 'charles' to /home/test1 (internal-sftp) and set the chroot folder ownership/permissions (root:root, 755)
    • Shell commandprintf '\nMatch User charles\n ChrootDirectory /home/test1\n ForceCommand internal-sftp\n AllowTcpForwarding no\n X11Forwarding no\n' | sudo tee -a /etc/ssh/sshd_config >/dev/null && echo password | sudo -S chown root:root /home/test1 && echo password | sudo -S chmod 755 /home/test1 && echo '--- tail ---' && tail -n 8 /etc/ssh/sshd_config && echo '--- stat ---' && stat -c '%U:%G %a %n' /home/test1failed
  4. Step 42:02

    I need to fix the command so that sudo tee gets its password. The cleanest approach is to write the Match block to a temp file first, then use `echo password | sudo -S tee -a` to append it. Let me restructure the whole command.

    • Shell commandecho password | sudo -S bash -c 'printf "\nMatch User charles\n ChrootDirectory /home/test1\n ForceCommand internal-sftp\n AllowTcpForwarding no\n X11Forwarding no\n" >> /etc/ssh/sshd_config && chown root:root /home/test1 && chmod 755 /home/test1' && echo '--- tail ---' && tail -n 8 /etc/ssh/sshd_config && echo '--- stat ---' && stat -c '%U:%G %a %n' /home/test1
  5. Step 52:28

    Subgoal 2 is complete. Now I need to run 'sudo sshd -t' to validate the SSH configuration (subgoal 3).

    • Subgoal completedsshd_config has Match User charles block with ChrootDirectory /home/test1 and ForceCommand internal-sftp; /home/test1 is root:root 755.
    • In progressVerify the SSH configuration is valid and sshd is available
    • Shell commandecho password | sudo -S sshd -t 2>&1failed
  6. Step 62:50

    sshd is typically at /usr/sbin/sshd on Ubuntu, which isn't in sudo's default secure PATH. I'll run the config test using the full path. I'll also confirm openssh-server is installed.

    • Shell commandecho password | sudo -S /usr/sbin/sshd -t 2>&1; echo "exit=$?"; dpkg -l openssh-server 2>/dev/null | tail -1
  7. Step 73:24

    The core task (create charles with password, chroot config to /home/test1, folder perms) is done. The verification step failed only because the sshd binary isn't installed. Installing openssh-server is the standard, reversible way to make the SSH user functional and to validate the config with sshd -t. I'll install it non-interactively, then run the config test.

    • Shell commandecho password | sudo -S env DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::=--force-confold openssh-server 2>&1 | tail -n 5; echo '--- test ---'; echo password | sudo -S /usr/sbin/sshd -t 2>&1; echo "sshd_t_exit=$?"; pgrep -a 'apt|dpkg'failed
  8. Step 84:03

    All three subgoals are complete: user charles created with home /home/test1 and correct password; sshd_config has the Match User charles chroot block and /home/test1 is root:root 755; sshd -t validates cleanly. I can finish.

    • Subgoal completedopenssh-server installed; /usr/sbin/sshd -t exits 0 with no errors.
    • Reported as completed