首页 > 解决方案 > 如何通过 SSH 连接到 circleci@xxx 并访问实际的构建容器?

问题描述

夏天的

我将在 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. 使用 SSH 返回工作
  2. SSH 到正在运行的作业 在此处输入图像描述
  3. 看到 usr 是 root@xxx,而不是 circleci@xxx 在此处输入图像描述

标签: sshcircleci

解决方案


我得到了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 之后,我得到了实际的内容。

在此处输入图像描述


推荐阅读