Hi there,
I have a docker image based on lscr.io/linuxserver/openssh-server:latest
.
Here’s the script I use as my entrypoint:
#!/bin/bash
# User configuration file (expected to be mounted as a Kubernetes Secret)
USER_CONFIG_FILE="/etc/sftp-users.conf"
# Check if the user configuration file exists
if [[ -f "$USER_CONFIG_FILE" ]]; then
echo "Processing user configuration from $USER_CONFIG_FILE..."
while IFS=: read -r username password homedir; do
[[ -z "$username" || "$username" =~ ^# ]] && continue
if id "$username" &>/dev/null; then
echo "User $username already exists, skipping creation..."
else
echo "Creating user: $username with home directory: $homedir"
useradd -m -d "$homedir" -s /bin/bash "$username"
mkdir -p "$homedir/uploads"
chown -R "$username:$username" "$homedir"
fi
echo "$username:$password" | chpasswd || echo "Failed to set password for $username"
done < "$USER_CONFIG_FILE"
echo "User configuration processed successfully."
else
echo "Warning: User configuration file not found at $USER_CONFIG_FILE"
fi
exec /init
My user config file looks like this:
user_one:password_one:/home/user_one user_two:password_two:/home/user_two
I can successfully log in as the first user in the USER_CONFIG_FILE
, however when logging in as the second user, I get “Failed to set uids to 1001.” and the connection gets terminated. What could be the cause?