Looking for git ssh key solution: Application Management > Deployment via Git - Fails


Issue 1 and 2 are to document a bug in the Admin UI. A solution to this UI feature is the preferred solutuion.
Issue 3 and 4 are current workaround suggestions that I need further assistance solving.

These are the docs that cover this:

#Issue nr 1:
Step 1: Generate key from the Admin UI: Application Management > Deployment via Git.
Step 2: Downoad key. (public key)
Step 2: Add key to Github repo as a deploy key: “Key is invalid” error.

After checking with the id_rsa.pub file generated in the application users .ssh/id_rsa.pub the file that is downloaded is missing the ‘+’ character - possibly a reg-exp error.

The file in the application users .ssh/id_rsa.pub is a valid key and is the same key as the one that is mangled by the admin UI.

#Issue nr 2:
After adding the valid key generated in the last issue as a deploy key to the github repo - the admin UI fails with an error: “An unexpected error has occcured”

After testing this on the command line by doing a git clone from the application user (via ssh) it fails with:
Failed to add the host to the list of known hosts (/home/121777.cloudwaysapps.com/ynwfpsshpe/.ssh/known_hosts).
Permission denied (publickey).

#Issue nr 3:
If the system implied by the admin UI does not work then there is still an issue with the docs for git from the command line.

I generated id_rsa.1 and id_rsa.1.pub in /home/master/.ssh/ but multiple key files in /home/master/.ssh are not recognized by ssh server.

So how do I register multiple ssh key files ?

I need 1 key for each application (as deploy key)

#Issue nr 4:
Addon Development.
After discussing this with support i was instructed to solve this with the API.

This is interesting and I will be looking to develop addons.

However my issue cannot be unique. So I will ask the community for anyone that has already solved this issue. Has anyone developed an addon to generate multiple ssh keys for git deployment already?



First two issues are coming because the downloaded SSH key adds space instead of + sign. Indeed this is a bug which needs to be resolved. Meanwhile, please copy the ssh key from “view ssh keys”. If you add this copied key at your Github account it will work without any issue.

Secondly, you can add multiple ssh keys in /home/master/.ssh folder. Let me explain how it will work in your case

Suppose, you add a first key as id_rsa, you can access your first repo easily.
Command : ssh-keygen -t rsa -C your_email@example.com

Now, if you want to add another key pair you can do this in the following way

  1. Make the prefix id_rsa same like ( id_rsa_repo1 and id_rsa_repo2 and so on)
  2. Register this key in ssh agent
    a) First check ssh-agent is running
    Command : eval "$(ssh-agent -s)"
    b) Add ssh key using the following command
    Command : ssh-add ~/.ssh/id_rsa_repo1

Please do the same for all. After this, you can fetch your all repos application wise without any issue. Feel free to ask if you have any other question regarding this.

Kind Regards


Thank you for your fast reply.

This is a solution but it needs to be repeated for each ssh login - its not permanent.

I am hopeful that you get the /home/master/applications/app_id/.ssh/id_rsa to work with git both in the admin UI and on the command line. The best solution is to allow me to login with the application credentials and use git on the command line with the /home/master/applications/app_id/.ssh/id_rsa generated in the admin UI




You are welcome. Yes I understand this but currently you can login to the server with ssh keys but cannot fetch the repository from git account using SSH keys. Unfortunately, it is not possible in the current stack. You can give this as a feedback at the http://feedback.cloudways.com/

Kind Regards