Last active
October 28, 2020 16:14
-
-
Save caliburn1994/91e8b8d1205ca03c2acee2a7d71318a3 to your computer and use it in GitHub Desktop.
Docker SSH Server + public key authentication . login as a normal user
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=www | |
mkdir data keys public | |
# copy public key to current dir, for safe. | |
cp ${HOME}/.ssh/id_rsa.pub public/ | |
docker run -ti -p 2222:22 \ | |
-v $(pwd)/public/id_rsa.pub:/etc/authorized_keys/$(user) \ | |
-v $(pwd)/keys/:/etc/ssh/keys \ | |
-v $(pwd)/data/:/data/ \ | |
-e SSH_USERS="${user}:48:48" \ | |
--name my-ssh \ | |
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=www | |
docker exec my-ssh chown ${user}:${user} /etc/authorized_keys/${user} | |
ssh ${user}@localhost -p 2222 | |
# stop | |
docker stop my-ssh | |
docker remove my-ssh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment