# SSH Connection (Linux/MacOS Terminal)

## Generating and Linking the Key

1. First, generate an SSH key. Open a terminal and enter the following command to create it:

```
ssh-keygen -t ed25519 -C "example.powershell@gmail.com"
```

In this example, an "ed25519" key will be generated with the comment "<example.powershell@gmail.com>" for future identification.

You can also specify a path where the key files will be saved. By default, keys are stored in `~/.ssh/id_ed25519.pub`. To set a custom path, add `-f` and specify it, for example:

```
ssh-keygen -t ed25519 -f ~/.ssh/my_new_key
```

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2Fz5uWdQClkpHTcdGvaZnZ%2FcreatedKeyPair.png?alt=media&#x26;token=13f61618-fcb8-4f7a-a19f-9ff8b10d4b2a" alt=""><figcaption><p>Creating the SSH Keys (pair)</p></figcaption></figure>

{% hint style="info" %}
By default, the key is saved at `Username/.ssh/id_ed25519.pub on macOS or /home/Username/.ssh/id_ed25519.pub` on Linux.
{% endhint %}

2. Next, you need to retrieve and copy the newly created public key. Enter the command:

```
cat ~/.ssh/id_ed25519.pub
```

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FwvvJo597YVQ2JqiADBW1%2FDisplayedKey.png?alt=media&#x26;token=1971ccf4-0618-4830-93c9-b81c1bb7957a" alt=""><figcaption><p>Public key</p></figcaption></figure>

3. Open the MikoPBX web interface and go to **System** → **General Settings**:
4. Paste your public key into the **"SSH Authorized Keys"** field:

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FRDlulHLP2Ej1Cmw3piUE%2FSshAuthorizedKeysField.png?alt=media&#x26;token=5ed131db-c0ca-4c46-8a7b-90ddfbd8012d" alt=""><figcaption><p>SSH Authorized Keys Field</p></figcaption></figure>

## Connecting via SSH

To connect via SSH, run the following command in your terminal:

```
ssh -i ~/.ssh/id_ed25519 root@mikopbxipadress
```

Replace the following with your actual parameters:

* The path to your SSH key (if different from default).
* The IP address of your MikoPBX in place of `mikopbxipadress`.

You will then be prompted for the SSH passphrase if you set one. Upon successful authentication, you will be connected to the MikoPBX console via SSH:

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FuU05yYaBwsMBS3pQRLbm%2FmikopbxconsoleSSH.png?alt=media&#x26;token=2e90a52d-c391-4179-b600-ebed3f5920e5" alt=""><figcaption><p>Successful connection!</p></figcaption></figure>
