Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Permission Denied (public key).

Anthony Daly
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 29, 2024


Here is a snippet from my YML file;

 

- step:

          name: Statically serve via server-handler and expose it to the internet via ngrok

          script:

            - ssh $USER@$SERVER #'cd /var/www/skillshare-scp-test && npm install --save serve-handler ngrok && node index.js'
The $USER and $SERVER variables have been defined in bitbucket repository variables.

I have generated an RSA SSH key pair through bitbucket of which I've added the public key to my AWS EC2 instance(Ubuntu AMI) in .ssh/authorized_keys.

 Here is the error I get through pipelines when I push my code:

 

1. + ssh $USER@$SERVER 'cd /var/www/skillshare-scp-test && npm install --save serve-handler ngrok && node index.js'
2.  Warning: Permanently added the ED25519 host key for IP address 'x.xx.xx.xxx' to the list of known hosts
3.  Permission denied (publickey)

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 30, 2024

Hey @Anthony Daly and welcome to the Community! 

The error message indicates that the key is not being recognized as an authorized key by the destination server.

Could you please confirm if you have added the public key that was generated in Pipelines to the path ~/.ssh/authorized_keys on your server? This file should be in the home directory of the same user you are providing in the SSH command ($USER).

If you confirm the key was added in the correct file and user on your EC2 instance, I would suggest that you try to :

  1. Create your own SSH key locally
  2. Add this key to ~/.ssh/authorized_keyson on your server
  3. Test connecting locally using this key to the SSH server
  4. If the connection works, delete the pipeline SSH key from the repository settings, and add your own locally created key pair
  5. Run the pipeline again (now it will use your own uploaded keys) and check if the authentication works.

Additionally, you can also include the verbose flags in the SSH command so it will output more logs that may help with the troubleshooting: 

ssh -Tvvv $USER@$SERVER 'cd /var/www/skillshare-scp-test && npm install --save serve-handler ngrok && node index.js'

Thank you, @Anthony Daly !

Patrik S

Suggest an answer

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

Atlassian Community Events