I'm having a problem on a Red Hat cluster. We want the users to be able to only sftp in, and only to their own home directory. Pretty standard.
So here's the setup. We have a folder structure /sftp-area/vendor/<user>. All users are a member of a group called "FileCollector". Here's what it looks like:
<snipped out other directories>
[root@PHAFTP002 /]# ls -la
total 36
drwxrwxrwx. 5 root FileCollector 4096 Jul 26 2022 ftp-area
[root@PHAFTP002 ftp-area]# ls -la
total 28
drwxrwxrwx. 5 root FileCollector 4096 Jul 26 2022 .
dr-xr-xr-x. 21 root root 278 Mar 27 09:14 ..
drwx------. 2 root root 16384 Jul 25 2022 lost+found
drwxr-x--x. 6 root root 4096 Jul 25 2022 nfsinfo
drwxrwxr-x. 10 root FileCollector 4096 Mar 27 10:53 vendor
[root@PHAFTP002 ftp-area]#
[root@PHAFTP002 vendor]# ls -la
total 40
drwxrwxr-x. 10 root FileCollector 4096 Mar 27 10:53 .
drwxrwxrwx. 5 root FileCollector 4096 Jul 26 2022 ..
drwxrwxr-x. 4 lowespro FileCollector 4096 Mar 27 11:19 lowespro
OK, so the user "lowespro" has a home directory of /ftp-area/vendor/lowespro.
[root@PHAFTP002 vendor]# cat /etc/passwd
lowespro:x:1009:1001::/ftp-area/vendor/lowespro/home:/bin/bash
[root@PHAFTP002 vendor]#
And is a member of the right group:
[root@PHAFTP002 vendor]# groups lowespro
lowespro : FileCollector
[root@PHAFTP002 vendor]#
We're chrooting like this:
# override default of no subsystems
# Subsystem sftp /usr/libexec/openssh/sftp-server
# Subsystem sftp internal-sftp -d /home
subsystem sftp internal-sftp
Match Group FileCollector
ChrootDirectory /ftp-area/vendor/%u
So why doesn't this work?
C:\Users\LeoneM\.ssh>sftp -v lowespro@phaserv2.pha.phila.gov
OpenSSH_for_Windows_8.6p1, LibreSSL 3.4.3
debug1: Reading configuration data C:\\Users\\LeoneM/.ssh/config
debug1: Reading configuration data __PROGRAMDATA__\\ssh/ssh_config
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to phaserv2.pha.phila.gov [192.168.1.100] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\LeoneM/.ssh/id_rsa type 0
debug1: identity file C:\\Users\\LeoneM/.ssh/id_rsa-cert type -1
debug1: identity file C:\\Users\\LeoneM/.ssh/id_dsa type -1
debug1: identity file C:\\Users\\LeoneM/.ssh/id_dsa-cert type -1
debug1: identity file C:\\Users\\LeoneM/.ssh/id_ecdsa type -1
debug1: identity file C:\\Users\\LeoneM/.ssh/id_ecdsa-cert type -1
debug1: identity file C:\\Users\\LeoneM/.ssh/id_ecdsa_sk type -1
debug1: identity file C:\\Users\\LeoneM/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file C:\\Users\\LeoneM/.ssh/id_ed25519 type -1
debug1: identity file C:\\Users\\LeoneM/.ssh/id_ed25519-cert type -1
debug1: identity file C:\\Users\\LeoneM/.ssh/id_ed25519_sk type -1
debug1: identity file C:\\Users\\LeoneM/.ssh/id_ed25519_sk-cert type -1
debug1: identity file C:\\Users\\LeoneM/.ssh/id_xmss type -1
debug1: identity file C:\\Users\\LeoneM/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.7
debug1: compat_banner: match: OpenSSH_8.7 pat OpenSSH* compat 0x04000000
debug1: Authenticating to phaserv2.pha.phila.gov:22 as 'lowespro'
debug1: load_hostkeys: fopen C:\\Users\\LeoneM/.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:1Hw82u5owS7cr9zQzV3RU3SNyUlSnGsc6pJc5B0Z4WQ
debug1: load_hostkeys: fopen C:\\Users\\LeoneM/.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 'phaserv2.pha.phila.gov' is known and matches the ED25519 host key.
debug1: Found key in C:\\Users\\LeoneM/.ssh/known_hosts:20
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: C:\\Users\\LeoneM/.ssh/id_rsa RSA SHA256:Wy0yaH0UaCLkk0vUqG1u0ROM9tVzqfg266MFe5KQXPQ
debug1: Will attempt key: C:\\Users\\LeoneM/.ssh/id_dsa
debug1: Will attempt key: C:\\Users\\LeoneM/.ssh/id_ecdsa
debug1: Will attempt key: C:\\Users\\LeoneM/.ssh/id_ecdsa_sk
debug1: Will attempt key: C:\\Users\\LeoneM/.ssh/id_ed25519
debug1: Will attempt key: C:\\Users\\LeoneM/.ssh/id_ed25519_sk
debug1: Will attempt key: C:\\Users\\LeoneM/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com,webauthn-sk-ecdsa-sha2-nistp256@openssh.com>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Offering public key: C:\\Users\\LeoneM/.ssh/id_rsa RSA SHA256:Wy0yaH0UaCLkk0vUqG1u0ROM9tVzqfg266MFe5KQXPQ
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: C:\\Users\\LeoneM/.ssh/id_dsa
debug1: Trying private key: C:\\Users\\LeoneM/.ssh/id_ecdsa
debug1: Trying private key: C:\\Users\\LeoneM/.ssh/id_ecdsa_sk
debug1: Trying private key: C:\\Users\\LeoneM/.ssh/id_ed25519
debug1: Trying private key: C:\\Users\\LeoneM/.ssh/id_ed25519_sk
debug1: Trying private key: C:\\Users\\LeoneM/.ssh/id_xmss
debug1: Next authentication method: password
lowespro@phaserv2.pha.phila.gov's password:
debug1: Authentication succeeded (password).
Authenticated to phaserv2.pha.phila.gov ([192.168.1.100]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: filesystem full
client_loop: send disconnect: Connection reset
Connection closed.
The log seems to indicate permissions, but I'm failing to see where:
[root@PHAFTP002 vendor]# service sshd status
Redirecting to /bin/systemctl status sshd.service
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; preset: enabled)
Active: active (running) since Thu 2025-03-27 14:32:17 EDT; 19min ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 114311 (sshd)
Tasks: 1 (limit: 74501)
Memory: 1.4M
CPU: 710ms
CGroup: /system.slice/sshd.service
└─114311 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"
Mar 27 14:32:43 PHAFTP002.pha.phila.gov sshd[114622]: Accepted password for lowespro from 192.168.1.2 port 10032 ssh2
Mar 27 14:32:44 PHAFTP002.pha.phila.gov sshd[114622]: pam_unix(sshd:session): session opened for user lowespro(uid=1009) by lowespro(uid=0)
Mar 27 14:32:44 PHAFTP002.pha.phila.gov sshd[114622]: fatal: bad ownership or modes for chroot directory component "/ftp-area/" [postauth]
Mar 27 14:32:44 PHAFTP002.pha.phila.gov sshd[114622]: pam_unix(sshd:session): session closed for user lowespro
Mar 27 14:38:33 PHAFTP002.pha.phila.gov sshd[122289]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.1.2 user=lowespro
Mar 27 14:38:36 PHAFTP002.pha.phila.gov sshd[122289]: Failed password for lowespro from 192.168.1.2 port 10034 ssh2
Mar 27 14:50:27 PHAFTP002.pha.phila.gov sshd[137342]: Accepted password for lowespro from 192.168.1.2 port 10035 ssh2
Mar 27 14:50:28 PHAFTP002.pha.phila.gov sshd[137342]: pam_unix(sshd:session): session opened for user lowespro(uid=1009) by lowespro(uid=0)
Mar 27 14:50:28 PHAFTP002.pha.phila.gov sshd[137342]: fatal: bad ownership or modes for chroot directory component "/ftp-area/" [postauth]
Mar 27 14:50:28 PHAFTP002.pha.phila.gov sshd[137342]: pam_unix(sshd:session): session closed for user lowespro
I'm missing something simple here, but what??
Thanks
--