mirror of
https://github.com/luzifer-docker/sftp-share.git
synced 2024-12-20 22:11:16 +00:00
21 lines
613 B
Bash
Executable file
21 lines
613 B
Bash
Executable file
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
for type in rsa dsa ecdsa ed25519; do
|
|
if ! [ -e "/ssh/ssh_host_${type}_key" ]; then
|
|
echo "/ssh/ssh_host_${type}_key not found, generating..."
|
|
ssh-keygen -f "/ssh/ssh_host_${type}_key" -N '' -t ${type}
|
|
fi
|
|
|
|
ln -sf "/ssh/ssh_host_${type}_key" "/etc/ssh/ssh_host_${type}_key"
|
|
done
|
|
|
|
if ( id ${USER} ); then
|
|
echo "INFO: User ${USER} already exists"
|
|
else
|
|
echo "INFO: User ${USER} does not exists, we create it"
|
|
ENC_PASS=$(echo ${PASS} | openssl passwd -1 -stdin)
|
|
useradd -d /data -m -p ${ENC_PASS} -u ${USER_UID} -s /bin/sh ${USER}
|
|
fi
|
|
|
|
exec /usr/sbin/sshd -D
|