Pipeline git-ftp sftp SSH keys convert to PEM

Ladislav Janeček September 14, 2020

I was trying use git-ftp for deplyment via SFTP.

1) default git-ftp does not support sftp, so I use some updated image with madshansen/docker-git-ftp:latest with libssh2 and some specific version of curl

2) at the pipeline configuration, I create SSH key, if I understand, the path to the key is ~/.ssh/config

3) at the yaml file I have this script:

git ftp push --auto-init --insecure -vv -u $USERNAME --key ~/.ssh/config sftp://$SERVER --remote-root /var/www/doman.tld

git-ftp return:

+ git ftp push --auto-init --insecure -vv -u $USERNAME --key ~/.ssh/config sftp://$SERVER --remote-root /var/www/
Mon Sep 14 17:45:42 UTC 2020: git-ftp version 1.3.3 running on Linux 6936dbbe-64ba-44d4-a3d2-8b0d52b4796c-fhcj8 4.19.128-flatcar #1 SMP Tue Jun 16 10:17:17 -00 2020 x86_64 x86_64 x86_64 GNU/Linux
Mon Sep 14 17:45:42 UTC 2020: Auto init if needed.
Mon Sep 14 17:45:42 UTC 2020: Insecure SSL/TLS connection allowed
Mon Sep 14 17:45:42 UTC 2020: Host is 'domain.tld'.
Mon Sep 14 17:45:42 UTC 2020: User is 'disruptive'.
Mon Sep 14 17:45:42 UTC 2020: No password is set.
Mon Sep 14 17:45:42 UTC 2020: Using ssh private key file /root/.ssh/config
Mon Sep 14 17:45:42 UTC 2020: Using ssh public key file /root/.ssh/config.pub
Mon Sep 14 17:45:42 UTC 2020: Path is '/var/www/'.
Mon Sep 14 17:45:42 UTC 2020: Syncroot is ''.
Mon Sep 14 17:45:42 UTC 2020: The remote sha1 is saved in file '.git-ftp.log'.
Mon Sep 14 17:45:42 UTC 2020: CACert is ''.
Mon Sep 14 17:45:42 UTC 2020: Insecure is '1'.
Mon Sep 14 17:45:42 UTC 2020: Retrieving last commit from sftp://disruptive:***@domain.tld//var/www/.
* Trying 0.159.135.70...
* TCP_NODELAY set
* Connected to domain.tld (0.159.135.70) port 22 (#0)
* SSH MD5 fingerprint: *******
* SSH authentication methods available: publickey
* Using SSH public key file '/root/.ssh/config.pub'
* Using SSH private key file '/root/.ssh/config'
* SSH public key authentication failed: Unable to open public key file
* Failure connecting to agent
* Authentication failure
* Closing connection 0
curl: (67) Authentication failure
Mon Sep 14 17:45:43 UTC 2020: Check if sftp://disruptive:***@domain.tld is accessible.
* Trying 0.159.135.70...
* TCP_NODELAY set
* Connected to domain.tld (18.159.135.70) port 22 (#0)
* SSH MD5 fingerprint: *******
* SSH authentication methods available: publickey
* Using SSH public key file '/root/.ssh/config.pub'
* Using SSH private key file '/root/.ssh/config'
* SSH public key authentication failed: Unable to open public key file
* Failure connecting to agent
* Authentication failure
* Closing connection 0
curl: (67) Authentication failure
Mon Sep 14 17:45:44 UTC 2020: fatal: Can't access remote 'sftp://disruptive:***@domain.tld 

 

In the end, it looks that parameter --pubkey is required and the private key is not readable from bitbuckeg path .ssh/config or it is in a different format.

With pem and pub generate via ssh-keygenit it works.

1 answer

1 accepted

1 vote
Answer accepted
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 28, 2021

Hello @Ladislav Janeček,

I can see you had a support request open for this same issue (BBS-146071) that has been closed on the 9th of October for no reply, after the below message was sent to you:

In this case, would it be possible for you to try to use the below path for the private SSH key on Pipelines?

 

/opt/atlassian/pipelines/agent/ssh/id_rsa
git ftp push --auto-init --insecure -vv -u $USERNAME --key /opt/atlassian/pipelines/agent/ssh/id_rsa sftp://$SERVER --remote-root /var/www/doman.tld

 

If the issue still persists, try to add your credentials as part of the .git/config file on Pipelines.
Reference: https://github.com/git-ftp/git-ftp/issues/313#issuecomment-271265267

Let me know how it goes, Ladislav.

 

Can you kindly clarify whether this solved your issue or if further help is needed? 

 

 

Cheers,
Dario

Ladislav Janeček January 29, 2021

Hello, yes, the problem was solved, thank you.

Like Dario B likes this
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 29, 2021

Thanks a lot for confirming @Ladislav Janeček . 

Enjoy the weekend! :) 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events