1

I am struggling with a problem regarding a simple sftp server with a chroot setup on a Raspberry Pi. In partcular, when I connect to the sftp server and I try to create a folder I get "Couldn't create directory: Failure".

I created a user called andrea_share within the group sftp_users

# adduser --no-create-home andrea_share
# usermod -a -G sftp_users andrea_share
# usermod --shell /usr/bin/nologin andrea_share

Then, I created the sftp folder in /dir_sftp/andrea/share with the following permissions:

drwxr-xr-x 3 root root 4096 XXX XX XX:XX dir_sftp
drwxr-xr-x 3 root root 4096 XXX XX XX:XX andrea
drwxr-xr-x 3 andrea_share sftp_users 4096 XXX XX XX:XX share

The sshd_config file has been modified as:

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

and at the end of the file

Match User andrea_share
    ChrootDirectory /dir_sftp/andrea
    ForceCommand internal-sftp
    PasswordAuthentication yes
    AllowTCPForwarding no
    X11Forwarding no

The PasswordAuthentication and X11Forwarding are required because they are previously set to no and yes, respectively

I tried to reboot the system, and to update the packages without success.

UPDATE 15/12/2020

This is the output that I get when I try to create a folder in /share

sftp> pwd
Remote working directory: /share
sftp> mkdir ./test
Couldn't create directory: Failure

Additionally, I am able to remove files from the /share folder, but I am not able to upload files. This is an example of the output that I get:

sftp> put ./test.jpg
Couldn't write to remote file "/share/test.jpg"

where test.jpg is an test picture on my local machine.

4
  • What directory are you trying to create? What directory are you trying to create it in? In other words, what is the absolute pathname (relative to the chroot) of the directory that you're trying to create when it fails? – Kenster Dec 15 '20 at 0:08
  • Thanks @Kenster, I updated the question with additional information – batticiof Dec 15 '20 at 10:31
  • Are you using "andrea_share" as the target user account for logging in to the SFTP service? – roaima Dec 15 '20 at 11:27
  • 1
    @roaima yes sftp andrea_share@192.168.178.2 – batticiof Dec 15 '20 at 11:48
1

Problem solved. For a wrong setting of my rsync, the drive with the sftp folder was full. After cleaning the drive, the sftp server works correctly. Sorry, it was my mistake.

0

You can't create a directory in the target user's home directory because it's (correctly) owned by root with only root permitted to write to it. That's why you've created the share subdirectory - you can create and delete files/directories in there.

(This isn't Windows; rarely will rebooting make the system do something different. There are good reasons why rebooting works so well for Windows, but they're out of scope here.)

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.