-
-
Notifications
You must be signed in to change notification settings - Fork 733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add user before boot-up. #161
Comments
Hi, we can restore a dump (a json file) but the service must be started. Restoring a dump before starting the service is currently only supported for the memory provider. A single user can be created in portable mode via CLI arguments or env vars. Creating a new user using username and password is ok in simple use cases, we have a lot of parameters, we probably need to expose all of them if we want to support this feature. |
Likely the best and easier choice to implement on the Dockerfile side of things (either or will work). Either way would add the following support:
Env variables, specifically, would have make no difference within
To clarify, whichever way would still have the |
I made a "boot-leg" solution for my use case. Since the REST API is always on, I created a new folder called set_username() {
if [[ -z "$1" ]]; then
username="admin"
else
username="$1"
fi
}
set_password() {
if [[ -z "$1" ]]; then
password="secret"
else
password="$1"
fi
}
# Sets the username and password to the env variable.
set_username ${SFTPGO_USERNAME}
set_password ${SFTPGO_PASSWORD}
# Sends web request to API to add username and password.
curl --header "Content-Type: application/json" \
--request POST \
--data '{"username": "'${username}'", "password": "'${password}'", "status": 1, "home_dir": "/app/data/", "permissions": {"/": ["*"]}}' \
http://127.0.0.1:8080/api/v1/user And then have all the shell files inside of
Simply calling the below works.
|
Hi, I think using the REST API is the right way to add users, this way we can avoid to use data provider specific code, we could also restore a provider independent dump file. We could allow to execute custom scripts from a specific folder, so the users can customize things. I think your We should execute |
after 600a107 we can call |
Okay, understood. Let me ask you this: Is there a command line utility to add users, or is the REST API the only way? With Docker, it is my opinion, the user should be able to test out the SFTP server via a single command line utility. That is, simply running (the below) without any SFTPGo files present on their machine should be enough to query DockerHub for the
Is it your choice to limit the users account creation to specifically the web portal? I'm trying to understand how you would like to go about it so I can implement the Dockerfile accordingly. :) |
Also, is there a list of all available ENV variables for which sftpgo/docker/sftpgo/debian/Dockerfile Line 68 in a9e21c2
|
Hi, first of all thank you for working on this, I would like to help but I'm quite busy and I can only do quick tasks on SFTPGo at the moment. Regarding your questions:
I agree that we should be able to run SFTPGo for testing purpose with a command like this:
user creation should be optional. Maybe a convenient API to create users is the |
Hi, please give a try to the package here https://github.com/users/drakkan/packages/container/package/sftpgo @sagikazarmark did a great work! Documentation will follow, maybe after 1.1.0 release Regarding the feature you requested here I think I'll add a new configuration that allow to restore users from a backup something like Creating users from env var is not easy we have a lot of options, you could simply create on or more users from a test instance, create a dump via REST API and let SFTPGo restore this dump on startup. |
Ideally, the official docker image should be free of custom logic and should serve as a base for customizations. The image produced by the current Dockerfile allows you to build a custom image and run sftpgo in portable mode with the desired environment variables. |
If you need a single user overriding the default CMD and using the portable mode is the way to go. I'm wondering if it could be useful to have a shortcut to restore a backup on startup as alternative to the REST API. |
I'm generally against everything, that magically modifies state on startup. 😄 It's a loaded gun aimed at your foot. |
Wondering if there is some sort of environmental variable or file that can be utilized to boot-up the initial user(s) to the service. In relation to #159, this would be an environmental variables that can be set by the user on start:
Following the pattern suggest on #159 (comment),
atmoz/sftp
currently uses ausers.conf
to store initial user information, as well as accept the initial user configuration as a param on startup.Configuration File
users.conf
Start-up Command
Reference here.
This works due to the definition of the
Dockerfile
here:Which initializes the shell
entrypoint
file here, and executes:And adds user to the newly generated configuration file in which
atmoz/sftp
then reads to provide initial authentication. Despite howatmoz/sftp
implements this solution, I would stress a simple environmental variable that is read on start-up and written to the database as an authorized admin user.The text was updated successfully, but these errors were encountered: