我试图从Codeship上的容器推送到github。收到Permission denied (publickey)错误后,我在这里遵循了建议:

https://documentation.codeship.com/pro/builds-and-configuration/setting-ssh-private-key/

我创建了一个名为publish的服务,并尝试了一些步骤来尝试重新创建文章的建议。

我的codeship_services.yml文件:

# codeship_services.yml
publish:
  build:
    image: codeship/setting-ssh-key-test
    dockerfile: Dockerfile.publish
  encrypted_env_file: codeship.env.encrypted
  volumes:
    - ./.ssh:/root/.ssh

我的codeship_steps.yml文件:
- name: temp publish service
  service: publish
  command: /bin/bash -c "echo -e $PRIVATE_SSH_KEY >> /root/.ssh/id_rsa"

- name: chmod id_rsa
  service: publish
  command: chmod 600 /root/.ssh/id_rsa

- name: add server to list of known hosts
  service: publish
  command: /bin/bash -c "ssh-keyscan -H github.com >> /root/.ssh/known_hosts"

- name: confirm ssh connection to server, authenticating with generated public ssh key
  service: publish
  command: /bin/bash -c "ssh -T [email protected]"


但是,当运行jet steps时,仍然出现Permission denied (publickey)错误:
(step: temp_publish_service) success ✔
(step: chmod_id_rsa)
(step: chmod_id_rsa) success ✔
(step: add_server_to_list_of_known_hosts)
(service: publish) (step: add_server_to_list_of_known_hosts) # github.com:22 SSH-2.0-babeld-80573d3e
(service: publish) (step: add_server_to_list_of_known_hosts) # github.com:22 SSH-2.0-babeld-80573d3e
(service: publish) (step: add_server_to_list_of_known_hosts) # github.com:22 SSH-2.0-babeld-80573d3e
(step: add_server_to_list_of_known_hosts) success ✔
(step: confirm_ssh_connection_to_server,_authenticating_with_generated_public_ssh_key)
(service: publish) (step: confirm_ssh_connection_to_server,_authenticating_with_generated_public_ssh_key) Permission denied (publickey).
(step: confirm_ssh_connection_to_server,_authenticating_with_generated_public_ssh_key) error ✗
(step: confirm_ssh_connection_to_server,_authenticating_with_generated_public_ssh_key) container exited with a 255 code

我已经按照文章中的指示生成了密钥,并将加密的私钥添加到codeship.env.encryped中。

我有什么想念的吗?

最佳答案

唯一缺少的步骤是注册public Key on your GitHub account itself

只有这样,使用相同公共(public)密钥的SSH连接才有机会成功。

如果不是,请在最后一步中至少尝试使用ssh -Tvv [email protected],以获得更多线索。

08-27 12:11