如何通过 SSH 连接到 circleci@xxx 并访问实际的构建容器?

How to SSH to circleci@xxx and access to the actual build container?

夏天

我将在 CircleCI 2.0 上使用 SSH 访问构建容器。
我可以通过 SSH 连接到 运行 作业。但是用户不是circleci@xxx.
如何通过 SSH 连接到 circleci@xxx 并访问实际构建容器?

我试过的

  1. 将 SSH 密钥设置为 GitHub
❯ ssh git@github.com
PTY allocation request failed on channel 0
Hi jpskgc! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
  1. return 使用 SSH 的工作
  2. SSH 到 运行 作业
  3. 看到usr是root@xxx,不是circleci@xxx

circleci官方回复了

Hi,

Thanks for reaching out to us.

The container will use the default user for the image. 
In this case, you are using the ubuntu:18.04 image which defaults to root. 
This is because the ubuntu:18.04 is not a dedicated CircleCI convenience image.

You can check who the user is during a run by adding - run: whoami - in this instance it will return root.

The equivalent CircleCI image would be cimg/base:stable-18.04. 
You can find out more information about this image here: 
https://circleci.com/developer/images/image/cimg/base

As long as you SSH in via the details provided in the SSH step, 
you will be accessing the container in the same way as the job is run.

Adam

Senior Support Engineer @ CircleCI

在我的例子中,工作目录设置在 /go/src/mordpress-simulation

jobs:
  build:
    working_directory: /go/src/mordpress-simulation

所以,在cd /go/src/mordpress-simulation之后,我到达了实际内容