Created
October 26, 2020 16:10
-
-
Save caliburn1994/0db015e45846cfc41bd3ae674b64a695 to your computer and use it in GitHub Desktop.
Docker SSH Server - Password Auth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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