Skip to content

Instantly share code, notes, and snippets.

@caliburn1994
Created October 26, 2020 16:10
Show Gist options
  • Save caliburn1994/0db015e45846cfc41bd3ae674b64a695 to your computer and use it in GitHub Desktop.
Save caliburn1994/0db015e45846cfc41bd3ae674b64a695 to your computer and use it in GitHub Desktop.
Docker SSH Server - Password Auth
mkdir entrypoint.d keys
# for set password
user=user1
password=pass123456
salt="KdN5Re3X2X18"
hash_password=$(echo ${password} | mkpasswd --stdin --method=sha-512 --salt ${salt})
cat << EOF > entrypoint.d/setpasswd.sh
#!/usr/bin/env bash
set -e
echo '${user}:${hash_password}' | chpasswd --encrypted
echo "The Script Is Finished"
EOF
chmod u+x entrypoint.d/setpasswd.sh
# docker
docker run -ti \
-p 2222:22 \
-v $(pwd)/entrypoint.d/:/etc/entrypoint.d/ \
-v $(pwd)/keys/:/etc/ssh/keys \
-e SSH_USERS=${user}:1000:1000 \
-e SSH_ENABLE_PASSWORD_AUTH=true \
docker.io/panubo/sshd:1.3.0
user=user1
password=pass123456
ssh ${user}@localhost -p 2222
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment