Zaher Ghaibeh
PHP Backend developer
I've experience in a few PHP Frameworks, such as Laravel, Lumen and Slim (The last two are used for building Microservices/API services).
How to use Deployment keys
Published at Friday, July 10, 2015 , Categorized under: Code, Linux

In general Deployment keys is used to give a read only access to your git repository, which I think its the best options which you should use on your Production Server, at the end you don't need to change anything on your production server, nor you want any changes to reflect or appear on your master branch.

Creating SSH key on Production Server:

You will have to create SSH key for your server which you will use to give access to your repository.

$ ssh-keygen -t rsa -b 4096 -C "servername@yourcompany.com"

after you finish generating the key you will find it the Private and the Public keys with in the \~/.ssh directory.

we need to copy the content of the Public key to use it on our git hosting provider.

Adding Development Key to your git hosting provider:

  1. BitBucket:

You will need to go to the `Settings` tab of your repository and click on `Deployment Keys` and add the content of your server Public key to it

  1. GitHub:

As in bitbucket you will need to go to the Settings tab and click on Deploy keys and then add the content of your server Public key.

PS: you need to notice that github gives you the ability to give write access to this key, which I don't encourage you to do, unless you have some important reasons to do so.