I am attempting to push to github from a container on Codeship. After getting a Permission denied (publickey)
error, I followed the suggestion here:
https://documentation.codeship.com/pro/builds-and-configuration/setting-ssh-private-key/
I created a service called publish
to and some steps to try to recreate the article's suggestion.
My codeship_services.yml file:
# codeship_services.yml
publish:
build:
image: codeship/setting-ssh-key-test
dockerfile: Dockerfile.publish
encrypted_env_file: codeship.env.encrypted
volumes:
- ./.ssh:/root/.ssh
My codeship_steps.yml file:
- 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 git@github.com"
When running jet steps
, however, I still get the Permission denied (publickey)
error:
(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
I have generated the keys as instructed in the article and added the encrypted private key to codeship.env.encryped
.
Is there something I am missing?
The only missing step would be to register the public Key on your GitHub account itself
Only then an SSH connection using that same public key would have a chance to succeed.
If not, try at least an ssh -Tvv git@github.com
in your last step, in order to get more clues.