# Generate SSH Keys

To generate SSH keys, ensure that you have `ssh-keygen` command-line tool installed. `ssh-keygen` is a utility for generating SSH key pairs and storing them in a secure location. With these keys, you can connect to your instances without encountering the login prompt. You can use the SSH keys on a macOS or a Linux using an SSH client.

You can manually generate SSH keys when working with a SSH client using the following:

1. Enter the following command into the terminal window on your computer and press **ENTER**.

{% tabs %}
{% tab title="Bash" %}

```bash
ssh-keygen
```

{% endtab %}
{% endtabs %}

{% hint style="success" %}
**Result:** The key generation process is initiated by the command above. When you run this command, the `ssh-keygen` utility prompts you for a location to save the key.
{% endhint %}

2. Accept the default location by pressing the **ENTER** key, or enter the path to the file where you want to save the key `/home/username/.ssh/id_rsa`.

{% tabs %}
{% tab title="Bash" %}

```bash
Enter file in which to save the key (/home/username/.ssh/id_rsa):
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
**Warning:** If you have previously generated a key pair, you may see the following prompt. If you choose to overwrite the key, you will no longer authenticate with the previous key.
{% endhint %}

{% tabs %}
{% tab title="Bash" %}

```bash
/home/username/.ssh/id_rsa already exists.
Overwrite (y/n)?
```

{% endtab %}
{% endtabs %}

3. Enter the passphrase that will be used to encrypt the private key file on the disk. You can also press **ENTER** to accept the default (no passphrase) SSH key. However, we recommend that you use a passphrase.
4. Enter your passphrase once more.

{% hint style="success" %}
**Result:** After you confirm the passphrase, the public and private keys are generated and saved in the specified location.<br>

* The public key is saved in the `id_rsa.pub` file. Remember to upload this key to your [<mark style="color:blue;">DCD</mark>](https://docs.ionos.com/cloud/support/general-information/glossary-of-terms#dcd) account.<br>
* Your private key is saved in the `id_rsa` file in the `.ssh` directory and is used to verify if the public key you use belongs to the same DCD account.\
  You will receive a similar confirmation message:
  {% endhint %}

{% tabs %}
{% tab title="Bash" %}

```bash
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:AcP/ieiAOoD7MjrKepXks/qHAhrRasGOysiaIR94Quk username@mb01739.local
The key's randomart image is:
+---[RSA 3072]----+
|     .o          |
|      .o         |
|..     ..        |
|.oo .   ..       |
|+=.+ . .So .     |
|X+. * . . o      |
|&Eo. *           |
|&Oo.o o          |
|@O++..           |
+----[SHA256]-----+
```

{% endtab %}
{% endtabs %}

You can copy the public key to your clipboard by running the following command:

{% tabs %}
{% tab title="Bash" %}

```bash
 pbcopy < ~/.ssh/id_rsa.pub
```

{% endtab %}
{% endtabs %}
