Configuring a requests group for SFTP

Ubuntu Support Template

Ubuntu Version:
24.04

Desktop Environment (if applicable):
XFCE

Problem Description:
I am trying to set up a remote user group that is restricted to my home/Requests folder. The idea is that they can connect and drop tracks which a Python script will pick up on a state change using watchdog and then send the URI to Liquid Soap for a jukebox-type request queue that bypasses AutoDJ.

Anyway, I can connect via SFTP with my root user and see all of the directories, but I don’t want that for friends or co-workers connecting to make requests.

This is what I’ve updated the SSH configuration file with:

Match Group requests
ChrootDirectory /home/trekker182/Requests/
Subsystem sftp internal-sftp
AllowTcpForwarding no
X11Forwarding no
PermitTunnel no
PasswordAuthentication yes #

There is also a command before the requests group declaration:

Subsystem sftp /usr/lib/openssh/sftp-server

I then made a user part of that group called requests1 and performed the following commands:

sudo usermod -aG requests request1

sudo chown root:requests /home/trekker182/Requests/

I am trying to connect from a Windows 11 PC on the same network and turned on verbose mode and the connection gets reset for some reason.

Screenshots or Error Messages:

C:\Users\work>sftp -v request1@192.168.7.101
OpenSSH_for_Windows_9.5p2, LibreSSL 3.8.2
debug1: Connecting to 192.168.7.101 [192.168.7.101] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\work/.ssh/id_rsa type -1
debug1: identity file C:\\Users\\work/.ssh/id_rsa-cert type -1
debug1: identity file C:\\Users\\work/.ssh/id_ecdsa type -1
debug1: identity file C:\\Users\\work/.ssh/id_ecdsa-cert type -1
debug1: identity file C:\\Users\\work/.ssh/id_ecdsa_sk type -1
debug1: identity file C:\\Users\\work/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file C:\\Users\\work/.ssh/id_ed25519 type -1
debug1: identity file C:\\Users\\work/.ssh/id_ed25519-cert type -1
debug1: identity file C:\\Users\\work/.ssh/id_ed25519_sk type -1
debug1: identity file C:\\Users\\work/.ssh/id_ed25519_sk-cert type -1
debug1: identity file C:\\Users\\work/.ssh/id_xmss type -1
debug1: identity file C:\\Users\\work/.ssh/id_xmss-cert type -1
debug1: identity file C:\\Users\\work/.ssh/id_dsa type -1
debug1: identity file C:\\Users\\work/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_9.5
debug1: Remote protocol version 2.0, remote software version OpenSSH_9.6p1 Ubuntu-3ubuntu13.14
debug1: compat_banner: match: OpenSSH_9.6p1 Ubuntu-3ubuntu13.14 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.7.101:22 as 'request1'
debug1: load_hostkeys: fopen C:\\Users\\work/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:aR0sr8RIOTa3ioeNPdz77hiT0fo2H+jd0fmWyFkA7Ns
debug1: load_hostkeys: fopen C:\\Users\\work/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts2: No such file or directory
debug1: Host '192.168.7.101' is known and matches the ED25519 host key.
debug1: Found key in C:\\Users\\work/.ssh/known_hosts:1
debug1: ssh_packet_send2_wrapped: resetting send seqnr 3
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: ssh_packet_read_poll2: resetting read seqnr 3
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: get_agent_identities: ssh_get_authentication_socket: No such file or directory
debug1: Will attempt key: C:\\Users\\work/.ssh/id_rsa
debug1: Will attempt key: C:\\Users\\work/.ssh/id_ecdsa
debug1: Will attempt key: C:\\Users\\work/.ssh/id_ecdsa_sk
debug1: Will attempt key: C:\\Users\\work/.ssh/id_ed25519
debug1: Will attempt key: C:\\Users\\work/.ssh/id_ed25519_sk
debug1: Will attempt key: C:\\Users\\work/.ssh/id_xmss
debug1: Will attempt key: C:\\Users\\work/.ssh/id_dsa
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256>
debug1: kex_ext_info_check_ver: publickey-hostbound@openssh.com=<0>
debug1: kex_ext_info_check_ver: ping@openssh.com=<0>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: C:\\Users\\work/.ssh/id_rsa
debug1: Trying private key: C:\\Users\\work/.ssh/id_ecdsa
debug1: Trying private key: C:\\Users\\work/.ssh/id_ecdsa_sk
debug1: Trying private key: C:\\Users\\work/.ssh/id_ed25519
debug1: Trying private key: C:\\Users\\work/.ssh/id_ed25519_sk
debug1: Trying private key: C:\\Users\\work/.ssh/id_xmss
debug1: Trying private key: C:\\Users\\work/.ssh/id_dsa
debug1: Next authentication method: password
request1@192.168.7.101's password:
Authenticated to 192.168.7.101 ([192.168.7.101]:22) using "password".
debug1: channel 0: new session [client-session] (inactive timeout: 0)
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: filesystem
**client_loop: send disconnect: Connection reset**
Connection closed

Here are the logs from the ssh.service on the server:

Dec 03 13:41:02 trekker182-Inspiron-3668 sshd[1493508]: Accepted password for request1 from 192.168.7.115 port 54323 ssh2
Dec 03 13:41:02 trekker182-Inspiron-3668 sshd[1493508]: pam_unix(sshd:session): session opened for user request1(uid=1002) by request1(uid=0)
Dec 03 13:41:03 trekker182-Inspiron-3668 sshd[1493508]: pam_unix(sshd:session): session closed for user request1

I also tried connecting via WinSCP on the same Windows PC, but I didn’t get a specific error. It would give a generic error after entering the password.

Any help would be appreciated thanks! Every time I’ve made changes to the open ssh configration file, I would do systemctl daemon-reload & systemctl restart ssh.socket

Quoting from ‘man sshd_config’:

ChrootDirectory
Specifies the pathname of a directory to chroot(2) to after authentication. At session startup sshd(8) checks that all components of the pathname are root-owned directories which are not writable by any other user or group.

So I don’t believe you’ve got all components of the directory you want to chroot into as root-owned and non-writable by any other user (if your home-directory were root owned and only writeable by root, then how do you do any work ?). Try putting the chroot somewhere outside of /home.