# SSH Connection (Windows Powershell)

## Generating and Linking the Key

To begin, you need to install OpenSSH on Windows. You can do this from [this link](https://github.com/PowerShell/Win32-OpenSSH/releases).

1. After installation, verify it by entering the following command in PowerShell:

```
ssh -V
```

You should see the OpenSSH version displayed:

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FakU7UHPubqvNcguPzyis%2FsshVcommand.png?alt=media&#x26;token=fb731a03-505c-441b-a50c-dc0cec0c9464" alt=""><figcaption><p>OpenSSH version</p></figcaption></figure>

{% hint style="info" %}
If nothing happens when checking the version, you can run:

`Add-WindowsCapability -Online -Name OpenSSH.Client*`
{% endhint %}

2. Next, generate an SSH key by entering the following command:

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

This will generate an "ed25519" key with the comment "<example.powershell@gmail.com>" to identify it. You can specify a path for the keys by adding `-f` and a path, 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%2FAglQKnnA5dAWCvNa4Kr9%2FgeneratingKeys.png?alt=media&#x26;token=8db35fd7-b9ef-445b-b224-a2de3e622e51" alt=""><figcaption><p>Generating a Key in Powershell</p></figcaption></figure>

After this, the key pair will be created in the specified directory. One file will contain the public key, and the other the private key.

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FRYARq4upKAtsIVowXzt6%2Fimage.png?alt=media&#x26;token=81be8de3-b741-4258-bf04-e341597ff4b5" alt=""><figcaption><p>Generated keys (pair)</p></figcaption></figure>

3. Run the following command to retrieve the public SSH key:

```
Get-Content ~/.ssh/id_ed25519.pub
```

Copy the public key from the output.

4. Open the MikoPBX web interface and go to "**System" → "General Settings"**:

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FSNS9fu6Vh0TO5Fy6i9sC%2FgeneralSettingsSection.png?alt=media&#x26;token=d2025c2f-b079-4412-9cf8-ee62259a6de6" alt=""><figcaption><p>"General settings" section</p></figcaption></figure>

5. Navigate to the **SSH** section and paste the public key into the **"SSH Authorized Keys"** field in the following format:

```
KeyType KeyData
```

Click **"Save settings"**:

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2Fd2CAc0u8mnXY5zpnslcD%2FsshAuthorizedKeys.png?alt=media&#x26;token=35145e31-f4ac-4836-b278-4b3f8c01360c" alt=""><figcaption><p>"SSH Authorized Keys" field</p></figcaption></figure>

## Connecting via SSH

To connect via SSH, run the following command in PowerShell:

```
ssh -i C:\Users\<Username>\.ssh\id_ed25519 root@mikopbxipadress
```

Replace the following based on your parameters:

* The path to your SSH key.
* The IP address of your MikoPBX instead of `mikopbxipadress`.

You will then 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%2Fst1SB1n4dvN8FESfQFu0%2FsshConnection.png?alt=media&#x26;token=053372bd-5168-4e40-8995-88ae3768a5df" alt=""><figcaption><p>Successful connection!</p></figcaption></figure>
