Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/javanile/fake-ssh-server
Docker container which can be used in SSH integration tests
https://github.com/javanile/fake-ssh-server
bash docker integration-testing ssh ssh-server test-automation testing
Last synced: 18 days ago
JSON representation
Docker container which can be used in SSH integration tests
- Host: GitHub
- URL: https://github.com/javanile/fake-ssh-server
- Owner: javanile
- License: mit
- Created: 2020-07-05T20:16:42.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-07-20T19:57:19.000Z (over 4 years ago)
- Last Synced: 2023-02-27T14:51:33.870Z (almost 2 years ago)
- Topics: bash, docker, integration-testing, ssh, ssh-server, test-automation, testing
- Language: Dockerfile
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fake-ssh-server
![Lint Code Base](https://github.com/javanile/fake-ssh-server/workflows/Lint%20Code%20Base/badge.svg)
[![Build Status](https://travis-ci.org/javanile/fake-ssh-server.svg?branch=master)](https://travis-ci.org/javanile/fake-ssh-server)This is used as a dummy SSH server in some of our integration tests.
## Description
This is a lightweight SSH server in a docker container.
This image provides:
- An Ubuntu LTS base image
- Standard SSH server
- User creation based on env variable
- Home directory based on env variable
- Ability to run in chroot
- Ability to use SSH public key### Example
Mount contents of `./ssh-data` folder into sftp server inside container.
```yml
version: '2'services:
# SSHD Server
sshtest:
image: checkoutfinland/dummy-sftp-server
environment:
# (mandatory) Username for the login
USERNAME: sftp
# (optional) Use dummy ssh key you generated for this test
PUBLIC_KEY: ssh-rsa AAAA....
# (optional) Use custom path for AuthorizedKeysFile
PUBLIC_KEYS_PATH: /etc/ssh/authorized_keys
# (optional) Use the path of mapped volume, default: /in
FOLDER: /in
# (optional) put the $FOLDER inside chroot, default: 1
CHROOT: 1
# (optional) use custom port number, default: 22
PORT: 2238
cap_add:
# Required if you want to chroot
- SYS_ADMIN
security_opt:
# Required if you want to chroot
- apparmor:unconfined
ports:
- 2238:2238
volumes:
./ssh-data:/in
```Verify that it works by opening SSH shell to the docker container:
```
$ ssh -p 2238 ubuntu@localhost echo "Hello World!"
Hello World!
```### Configuration
Configuration is done through environment variables.
Required:
- USERNAME: the name for login.
- PUBLIC_KEY: the public ssh key for login. (you need this or password)
- PASSWORD: the password for login. (you need this or public key)
- FOLDER: the home of the user.Optional:
- CHROOT: if set to 1, enable chroot of user (prevent access to other folders than its home folder). Be aware, that
currently this feature needs additionnal docker capabilities (see below).
- OWNER_ID: the uid of the user. If not set automatically grabbed from the uid of the owner of the FOLDER.### Chroot
If you want to run the SSH server with chroot feature, the docker image has to be run with additional capabilities.
cap_add:
- SYS_ADMIN
security_opt:
- apparmor:unconfinedThis is due to the use of `mount --bind` in the init script.
**If someone has a better way to do, feel free to submit a pull request or a hint.**
## License
This software is under [MIT](LICENSE) license.