【问题标题】:connect bitbucket pipeline to cpanel with API keys使用 API 密钥将 bitbucket 管道连接到 cpanel
【发布时间】:2021-08-10 09:00:37
【问题描述】:

如何使用 SSH 密钥(从 cPanel 创建)连接到服务器?最终拉出一个新副本并运行作曲家更新和数据库迁移(一个 Symfony 脚本)

我收到权限被拒绝错误,所以我的ssh example.net.au ls -l /staging.example.net.au 正在访问服务器,我只是不确定如何使用 cPanel 制作的密钥进行身份验证。

bitbucket-pipelines.yml

# This is an example Starter pipeline configuration
# Use a skeleton to build, test and deploy using manual and parallel steps
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: atlassian/default-image:2

pipelines:
  default:
    - parallel:
      - step:
          name: 'Build and Test'
          script:
            - echo "Your build and test goes here..."
      - step:
          name: 'Lint'
          script:
            - echo "Your linting goes here..."
      - step:
          name: 'Security scan'
          script:
            - echo "Your security scan goes here..."

    # The following deployment steps will be executed for each pipeline run. To configure your steps and conditionally deploy see https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/
    - step:
        name: 'Deployment to Staging'
        deployment: staging
        script:
          - echo "Your deployment to staging script goes here..."
          - echo $TESTVAR
          - ssh example.net.au ls -l /staging.example.net.au
    - step:
        name: 'Deployment to Production'
        deployment: production
        trigger: 'manual'
        script:
          - echo "Your deployment to production script goes here..."

【问题讨论】:

  • 有趣的问题。找到后请发布解决方案。
  • 我会的,我使用他们说明中的实际示例向Atlassian forum 发布了一个类似的问题,也没有任何答案。
  • 所以看看人们试图从他们的服务器连接到 bitbucket,似乎 bitbucket 的 22 端口被阻塞,而 443 端口被阻塞。所以- ssh example.net.au -p 443 ls -l /staging.example.net.au 但现在我遇到了 ssh 错误,至少意味着我现在正在建立连接。可能只是我错误地安装了我的证书,当它完全工作时我会发布作为答案。
  • 对于其他提出这个问题的人来说,这不是端口问题,密钥设置不正确。

标签: cpanel ssh-keys bitbucket-pipelines


【解决方案1】:

我认为您的 SSL 设置可能不正确。请尝试以下方法以确保两台服务器相互信任:

==第 1 部分==

步骤 1. SSH 进入 cPanel 服务器(使用PuTTY 或您首选的 SSH 客户端),并运行以下命令生成新密钥:

ssh-keygen
eval $(ssh-agent)
ssh-add
cat ~/.ssh/id_rsa.pub

第 2 步。将上述“cat”命令生成的密钥复制到:Bitbucket -> your repo -> Settings -> Access keys

==第 2 部分==

第 3 步。在 Bitbucket 中,转到您的存储库 -> 设置 -> SSH 密钥 -> 生成密钥

第 4 步。返回您的 cPanel 服务器的 SSH 连接,将上述第 3 步中的密钥复制到授权密钥文件中。完成后保存:

nano ~/.ssh/authorized_keys

右键粘贴(通常) CNRL+O 保存 CNRL+X 退出

第 5 步。在与第 3 步相同的 Bitbucket 屏幕中,获取并添加主机的指纹。您需要在此处输入您的 cPanel 服务器的 URL 或 IP 地址。一些 cPanels 服务器使用非默认端口。如果端口 22 不是正确的端口,请务必指定如下:

example.com:2200

(端口 443 通常为 HTTPS 保留,它不太可能是 SSH 连接的正确端口。如果有疑问,请先尝试默认的 22 和常见的替代 2200 端口。)

如果您有任何问题,请告诉我,我很乐意为您提供进一步的帮助。

【讨论】:

  • 感谢您的详细回答。我必须使用 Putty Key Generator 生成一个密钥集并将其导入 cPanel(cPanel keygen 需要密码),因此这些步骤并未完全遵循,但为我指明了正确的方向。
猜你喜欢
  • 1970-01-01
  • 2012-03-18
  • 2017-11-06
  • 1970-01-01
  • 2015-08-13
  • 1970-01-01
  • 2017-12-23
  • 2023-02-03
  • 1970-01-01
相关资源
最近更新 更多