I want users can access via ssh to a container. Or, more precisely: host users can access to a containerized shell. This could look strange, but it works:
$ cat /etc/passwd | grep staging
staging:x:1001:1001::/home/staging:/usr/local/bin/stagingclish
$ groups staging
staging : staging docker
$ cat /usr/local/bin/stagingclish
#!/bin/sh
cd /home/cloud/docker/myproject-staging && docker-compose run --rm --entrypoint=bash php-cli $@
php-cli
is just a custom build from php:7.4-cli image, including some utilities like rsync. Also, /etc/passwd is mounted from host.
I can login with ssh staging@myhost
.
I can invoke commands:
ssh staging@myhost ls /
Creating myproject-staging_php-cli_run ...
Creating myproject-staging_php-cli_run ... done
CHANGELOG.md
COPYING.txt
Gruntfile.js.sample
...
Now I would like be able to use scp
and rsync
commands to retrieve/upload files from/to the container.
But:
scp staging@myhost:/var/www/repo/auth.json.sample .
Creating myproject-staging_php-cli_run ...
Creating myproject-staging_php-cli_run ... done
usage: scp [-346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program] source ... target
1
And
rsync staging@myhost:/var/www/repo/auth.json.sample .
[... rsync help ...]
rsync error: syntax or usage error (code 1) at main.c(1580) [client=3.1.3]
1
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(228) [Receiver=3.2.3]
I don't even know if this is possible. Could anyone bring some light?