SSH Access to GIT Repository

With Jelastic you can easily deploy your application from any remote public or private GIT/SVN repository for each of the supported programming languages: Java, PHP, Ruby, Python and Node.js.

In order to achieve more security, you can also access your private GIT repositories via SSH and easily clone and update your applications from them. In addition, this gives you an ability to work with those repositories, which are located at the private servers, instead of common web-based hosting services for projects like GitHub, Bitbucket etc.

Note: Your keys must not contain the password protection (passphrase) in order to be used for establishing a connection between Jelastic Cloud and GIT account.

Add Private SSH Key to Jelastic Account

Once you’ve got a pair of generated SSH keys, let’s place each of them to the appropriate systems. First of all, you need to add your private key to the Jelastic account.

1. Log in to your Jelastic account and navigate to its settings by means of clicking the same-named Settings button at the top-right section of the dashboard.

2.Within the opened Account Settings tab, switch to the Private option inside the SSH Keychain section and click on the Add Private Key button.

3. Copy your private SSH key and paste it to the Key text field. Then type a name for this key within the field above (e.g. git-key) and finish the addition with the Add Key button.

Note: If you’ve received an error while adding the key, make sure it is not protected with a passphrase. Otherwise, remove the protection and try again.

4. As a result, your new private key will appear in the corresponding tab in just a moment.

You are always able to delete your keys from a key manager by selecting the appropriate red cross button, if they aren’t needed anymore. Herewith, key’s deletion from the list won’t remove it from the GIT projects this key was used for, therefore you will be able to work with them in the same way as it was done before.

Add Public SSH Key to Git Account

After your private key has been uploaded to your Jelastic account, it’s time to adjust your GIT repository account.

If your GIT repository is located at the remote private server, just upload the appropriate SSH public key to it and add this key to the list of authorized ones.

In case you are using some web-based projects’ hosting service, follow the corresponding detailed step-by-step guide below. As an example, we’ll pay the attention to two most popular services, GitHub and Bitbucket.

GitHub

1.Log in to your GitHub account using your credentials. Go to account Settings (at the top right corner), choose the SSH keystab at the left pane and click on the Add SSH key button.

2.Paste your public SSH key to the Key input field, set a Title for your key (e.g. jelastic-sshkey) and click Add key.

3.Confirm the key addition by means of typing the password for your GitHub account in the opened frame and selecting the appropriate button.

4.Check your newly added key has appeared in the same SSH keys tab.

5.To get the SSH link to your project, navigate to the desired repository (you must be logged in) and switch the link type to SSH in the clone URL section at the right-hand pane. Then click on the Copy to clipboard button (or do it manually).

Bitbucket

1. Log in to the Bitbucket account using your credentials and choose the Manage Account option from the user’s settings menu at the top right corner of the page.

2.Once the account settings page is opened, switch to the SSH keys tab (inside the Security section) using the left-hand categories list. Then, select Add key within the central part of the page.

3.In the appeared frame, paste your public SSH key to the Key input field, set a Label for your key (e.g. jelastic-sshkey) and click the Add key button.

4.Check your newly added key has appeared in the same SSH keys tab.

5.To get an SSH link to your project, access the desired repository’s overview screen (you must be logged in) and switch the link type to SSH within the corresponding drop-down list at the top of the page. Copy the shown string.

Deploy the Project via SSH

Finally, now you can proceed to your project’s deployment via the secured connection.

1. Create a new environment with the required application server and click the Add project button next to it.

2. In the opened frame, switch to the Git tab and specify your data into the fields it contains. Let’s consider each of them:

Enter the .git SSH link to your project within the URL field:

in the case of web-services usage, paste the previously copied URL. Herewith, link’s git@ part will instantly disappear and automatically transferred to the Login field instead.

in the case your repository is located at a private server, link should be specified according to the username@host:{path_to_project}.git format.

Change Branch if needed.

The Use authentication section will be automatically expanded after you’ve entered an SSH link. Fields inside this section are aimed for filling in your authorization data (wherein the Login is already specified according to the point above). So, select the Access type option (obviously, we’ll use the SSH key type in this tutorial) and choose the private key, previously added to your account, within the Select key drop-down list.

In the Path field, type the context you would like your application to be deployed to (or just leave the default one).

In case of adding a repository to the Maven build node, you should additionally specify the name for your project in a separate field at the frame’s top and choose an environment your project will be deployed to.

Also, you can configure some additional options:

Ticking the Check and auto-deploy updates checkbox will enable an automatic periodic re-deployment of your project from the repository, which is only performed if the repository contains new code changes. Use the Check every (min) option to define the required frequency of your project’s updates.

The Checkout now option (ticked by default) is used to indicate whether you’d like to deploy your project just after its addition or to do this later. If this option is disabled, your repository’s configurations will be saved for a further deployment, which can be initiated by the auto-deploy feature (if it is enabled) or by selecting the Update from GIT button next to the added project.

The Auto resolve conflict option is also active by default and represents an analogue of the git reset –hard command. It is used to prevent the occurrence of merge conflicts while further project updates, which can take place if the same file was modified in both remote repository and your project, hosted at Jelastic Cloud. If such an issue arises, this contradictory file will be updated according to its repository version (which is considered as the correct one), discarding the locally made changes.

Note: Please DO NOT disable this option if you don’t know exactly what you are doing.

When all the data is entered, click Add to start the deployment.

3. Wait until your project is successfully deployed and click on the Config button next to your application server. You can ensure your project files are now available in the folder, named after the specified context (or in the default ROOT folder) inside the webroot directory.

4. Finally, you can click on Open in browser for your environment and ensure your application is running.

Now you can enjoy the highly protected interaction with one of the most popular version control systems and clone and/or update your projects, hosted at Jelastic Cloud, directly from your private GIT repositories via SSH.