SFTP Server - Configuration with multiple user and one super user

danje57

New Member
Joined
Sep 8, 2023
Messages
1
Reaction score
0
Credits
38
I need your help about configuration for my SFTP server on Ubuntu.
I've installed open ssh, I've created my key pair.
I've configured sshd_config, to allow only certificate authentication, and for each user I created a match user block with specific configuration: user sftp-service, use publikey, no X11, no tunnel etc.
I've created mu users, with no login option, I've created the .ssh with authorized_keys files according to permission
Chown myuser:myuser /home/mysuser
Chmod 700 /home/myuser
Chmod 600 /home/myusers/.ssh/authorized_keys.

I've also create a chroot directory
/sftp/chroot/

With inside a directory for all users
/sftp/chroot/myuser1
/sftp/chroot/myuser2
/sftp/chroot/myuser3
...

The sshd_config is configured accordingly.
However, now I need a sftp_app user which can read and write in all /sftp/chroot/ user directory.
To read / write file and move file into a DONE folder on each user directory.
Everything work well for the moment, but I don't know how to make the configuration for the sftp_app user.
Could you help me?
This is more information about my configuration:
  1. All users have their own puclic key for login
==> key in user directory: .ssh/authorized_keys
  1. all users are in their own group
report_user1:x:1001:1002:N/A,N/A,N/A,N/A,N/A:/home/report_user1:/usr/sbin/nologin
report_user2:x:1002:1003:N/A,N/A,N/A,N/A,N/A:/home/report_user2:/usr/sbin/nologin
report_user3:x:1003:1004:N/A,N/A,N/A,N/A,N/A:/home/report_user3:/usr/sbin/nologin
report_user4:x:1004:1005:N/A,N/A,N/A,N/A,N/A:/home/report_user4:/usr/sbin/nologin
report_user5:x:1005:1006:N/A,N/A,N/A,N/A,N/A:/home/report_user5:/usr/sbin/nologin

  1. My sftp folder is configured like this:
drwxr-xr-x 3 root root 4,0K Sep 5 12:36 sftp

In /sftp/
drwxr-xr-x 3 root root 4,0K Sep 5 12:36 MY_COMPANY

IN /sftp/MY_COMPANY
drwxr-xr-x 3 root root 4,0K Sep 5 12:36 chroot

Inside chroot all user have their own directory named with their username
d-wx------ 2 report_user1 report_user1 4,0K Sep 8 09:24 report_user1

So all user can access their own folder, without capability to list file but only to write file in their own directory.
  1. My sshd_config is configured with:
PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no
PermitEmptyPasswords no
Subsystem sftp internal-sftp
Match User report_user1,report_user2,report_user3,report_user4,report_user5
ForceCommand internal-sftp
PasswordAuthentication no
ChrootDirectory /sftp/MY_COMPANY/chroot/
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
PubkeyAuthentication yes

  1. Now, I need to have a user which will be used by an application to read all files and inject data in a database. This is why the user should have acces in read mode to all user folders. But also in write mode, as once injected in database files must be renamed as FILE_NAME.done
The database is not managed on my side. Application will use SFTP server and read information then inject it into the database. Developper will make a copy of the SFTP files on their server for injection into the DB. Once successfully copied on the application side, they will rename files as .done to indicate that file are processed.
The SFTP server will received .txt or .csv file. However, I'would like also to restrict to only such extension, bu I don't know how...
Regards.
 

Members online


Top