# SSH

Using the SSH protocol, you can connect and authenticate to remote servers and services. You can connect to **GitHub**, **GitLab**, and **bitbucket** using SSH keys instead of entering your username and personal access token each time. When you configure SSH, you must generate a new SSH key and add it to the SSH agent. Before you use the SSH key to authenticate, you must first add it to your **GitHub**, **GitLab**, or **bitbucket** account.

### **Creating SSH Key**

To create an SSH key for GitHub, GitLab, bitbucket, and in general follow the steps below.&#x20;

Generate the SSH key on your local machine. (You can also use the repo's links, and the steps are the same for all repos).

* **SSH Configuration to  the Github account**

  [https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent  ](<https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent&#xD;&#xA;>)
* **SSH Configuration to  the GitLab account**

  <https://docs.gitlab.com/ee/ssh/#generate-an-ssh-key-pair>
* **SSH Configuration to  the bitbucket account**&#x20;

  <https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/>

1. &#x20;Generating SSH key in local

   `$ ssh-keygen`                                                                                                                                                                         It will generate the ssh key in  **\~/.ssh/id\_rsa** and  **\~/.ssh/id\_rsa.pub**
2. &#x20;Add the public key (id rsa.pub) to the repository

   `$ cat ~/.ssh/id_rsa.pub  # copy the content`

   * **For Github**

     Github Profile photo —>Settings —>SSH and GPG keys —>Click New SSH key or Add SSH key —> Click Save.
   * **For GitLab**

     Select your avatar —>Preferences or (user settings)—>SSH keys—>Paste the key in the Key field—>Add a descriptive text in the title—>Click Add Key
   * **For Bitbucket**

     Personal settings from your avatar —> SSH keys  —> click Add key  —>Enter a Label —> Paste the public key in the field —>Click Save.

### **Creating “Known\_Hosts” file**

* **Generate the known\_hosts file**

  `# ssh-keyscan github.com >> ~/.ssh/known_hosts`

### **Configuring ISD using values.yaml**

**Part A:** Assuming you have a private key and a known hosts file to create a secret before installing the ISD.&#x20;

1. &#x20;Enable SSH option in the **Values.yaml**

   `sshkeysecret: true`                                                                                                                                                             `sshsecretName: ssh-secret`
2. Create a secret using the SSH private key and the known hosts for the github/gitlab/bitbucket.com to be installed in the ISD namespace.

   `# copy the private key(id_rsa/id_ed25519) to ssh file`
3. &#x20;Make sure the RSA private key is present in the SSH file.

   `# kubectl create secret generic ssh-secret --from-file=ssh --from-file=known_hosts -n <namespace>`

### **Configuring ISD Pipeline Promotion Manually to use SSH**

**Part B:** Assuming you've already finished ISD configuration and use SSH for pipeline promotion

1. Edit the secret called **git-token**

   `kubectl edit secret git-token -n`
2. It contains the key-value as below (Fill out only **git\_secret\_sshkey** )

```
apiVersion: v1
stringData:
  # Git token to access repo where pipeline stuff is stored
  git_secret_token: ""
  git_secret_sshkey: "<base64 encoded ssh private key>"
  git_pr_token: ""
kind: Secret
metadata:
  name: git-token
type: Opaque
```

{% hint style="info" %}
**Note: Leave the git secret token and git pr token values empty to use SSH.**
{% endhint %}

3\.  Provide **base64 encoded id\_rsa** private key for the **git\_secret\_sshkey**.&#x20;

&#x20;     Use the command below to encode the private key                                                                                                                                           `# cat ~/.ssh/id_rsa | base64 |  tr '\n' ' '`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.opsmx.com/opsmx-1/opsmx-context-engine/additional-resources/code-labs/ssh.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
