# SSH

The SSH data source in UI Bakery allows you to securely connect to remote servers and retrieve data for use in your UI Bakery applications. With this data source, you can seamlessly integrate data from various SSH-enabled sources, such as Linux servers, cloud instances, or network-attached storage (NAS) systems.

## Configuration

### Prerequisites

Before connecting your data source, you first need to connect to an SSH server. We'll be using a Linux-based server as an example.

#### Host server configuration

On your host server, you need to make sure that:

* The `sshd` service is started and port `22` is open for inbound connections.
* The server is accepting inbound connections from the UI Bakery instance. \
  If it's not possible to connect to the server from the UI Bakery instance, it's still possible to connect to it through the SSH tunnel and Bastion host.
* We recommend [creating an additional user](https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-ubuntu-20-04) with restricted permissions for SSH connections.
* You might also want to disable password authentication by editing the `/etc/ssh/sshd_config` file and adding the `PasswordAuthentication no` instruction. Afterwards, you will need to restart the sshd service, for instance, `sudo service sshd restart`.

#### Generate a key for ssh

For *key-based authentication*, you must generate a key for UI Bakery to connect to your host server. You can use the following command:

```bash
ssh-keygen -t ecdsa -m PEM -f ./private_key.pem
```

You can enter a passphrase for the key or leave it empty.

#### Add the key to your server's authorized keys list

In order to allow UI Bakery to connect to your Host machine as a specific user, you should login as that user and add your public key to the list of authorized keys. Usually, you will need to modify the `~/.ssh/authorized_keys` file and add your *public* key as a separate line there.

If you've generated the ssh key using the command in the section above, you can get your *public* key using the following command:

```bash
ssh-keygen -y -f ./private_key.pem
```

### Connecting the data source

1. On the **Data sources** page, click **Connect**, and select *SSH* in the Data sources list.
2. Fill in the SSH connection credentials based on your server authentication configuration.
3. Click **Test connection** to check whether the data source can be connected, and then click **Connect Datasource** to complete the setup.

<figure><img src="/files/OVhCtZsF04fzz7BPO2e1" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Your key must be in the PEM format, which means that it should include the `-----BEGIN EC PRIVATE KEY-----` and `-----END EC PRIVATE KEY-----` lines.
{% endhint %}

## Usage

Once you've established the connection between UI Bakery and SSH, you can start interacting with its data. For this purpose, you can use the [SSH Command](/reference/working-with-actions/ssh-command.md) action step.


---

# 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.uibakery.io/reference/data-sources/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.
