Trying to connect via SSH to an instance from inside a docker image.
>>> gcloud app instances ssh aef-default-vb6e0b04-054k --quiet --service default --version vb6e0b04 --project myproject --container="gaeapp" -- echo "OK"
Waiting for operation [apps/myproject/operations/856b8bb4-c359-4cee-937c-1b92f7218b11] to complete...done.
DEBUG: Running command [/usr/bin/ssh -T -i /root/.ssh/google_compute_engine -o CheckHostIP=no -o HostKeyAlias=gae.myproject.aef-default-vcb4f1c9-frn7 -o IdentitiesOnly=yes -o UserKnownHostsFile=/root/.ssh/google_compute_known_hosts [email protected] -- sudo docker exec -i gaeapp echo OK].
DEBUG: Executing command: ['/usr/bin/ssh', '-T', '-i', '/root/.ssh/google_compute_engine', '-o', 'CheckHostIP=no', '-o', 'HostKeyAlias=gae.myproject.aef-default-vcb4f1c9-frn7', '-o', 'IdentitiesOnly=yes', '-o', 'UserKnownHostsFile=/root/.ssh/google_compute_known_hosts', '[email protected]', '--', 'sudo', 'docker', 'exec', '-i', 'gaeapp', 'echo', 'OK']
Warning: Permanently added 'gae.myproject.aef-default-vcb4f1c9-frn7' (ED25519) to the list of known hosts.
[email protected]: Permission denied (publickey).
DEBUG: (gcloud.app.instances.ssh) [/usr/bin/ssh] exited with return code [255].
CodePudding user response:
After contacting Google Cloud Support, I was redirect to this ticket: https://issuetracker.google.com/issues/76024023
The issue is that you cannot connect when the local user is root
:
This is an intended behavior since "PermitRootLogin no" is configured on "sshd_config" of the GAE flex instances. You can switch to root user after connecting to GAE Flex VM by a non-root but sudoer user and then running "sudo su -" command.
Creating a new user in the Dockerfile solved the problem.