# How to configure SSH keys using cPanel

> Generate, import and authorise SSH keys in cPanel so you can log in to your account over SSH without a password.

Source: https://helpcenter.ruachost.com/cpanel/guides/how-to-configure-ssh-keys-using-cpanel/

When you log into your ruachost server using SSH, you typically enter a password. However, for automated tasks like database backups or allowing multiple users to securely transfer files via SFTP, requiring a password each time can be inconvenient or insecure. By using SSH keys, you can connect to your ruachost server without a password, enabling automatic logins for processes or improved security for multiple users.

## What are SSH Keys?

SSH keys are a pair of cryptographic keys (public and private) used for authenticating logins. The private key remains on your local machine, while the public key resides on the Ruachost server. You can also use passphrases for additional security.

## Steps to Configure SSH Keys

### Option 1: Generating a New SSH Key Pair in cPanel

1. **Log into ruachost cPanel**.
2. **Navigate to SSH Access**:
   - In the **Security** section, click on **SSH Access**.
3. **Generate a New Key**:
   - Click **Manage SSH Keys**, then **Generate a New Key**.
   - Confirm **Key Name** is set to `id_rsa`.
   - Enter a **Key Password** or use the **Password Generator**.
   - Ensure **Key Type** is set to **RSA** and **Key Size** is **2048**.
   - Click **Generate Key**.
   - Once generated, the keys will be saved in `/home/username/.ssh/`.
4. **Authorize the Public Key**:
   - Under **Public Keys**, locate the newly created key and click **Manage**.
   - Click **Authorize** to enable it for SSH access.

### Option 2: Importing an Existing SSH Key

1. **Log into ruachost.com cPanel**.
2. **Navigate to SSH Access**.
3. **Import Your Existing Key**:
   - Under **Manage SSH Keys**, click **Import Key**.
   - Enter a name and paste your public key into the text box.
   - Click **Import**.
4. **Authorize the Imported Key**:
   - Find your imported key under **Public Keys**, click **Manage**, and **Authorize**.

## Connecting to ruachost with SSH Keys

### For Windows Users:

#### Option 1: Using PuTTY

1. Deploy the private key to your local computer by:
   - Downloading the key from **Private Keys** in **SSH Access** and converting it to **PPK** format.
   - Save the key on your local machine.
2. **Configure PuTTY**:
   - Open PuTTY and navigate to **SSH > Auth**.
   - Load your `.ppk` private key file.
   - Under **Session**, enter `username@ruachost.com` with the port set to **7822**.
   - Save the session and connect.

#### Option 2: Using Windows Native SSH Client

1. Download the private key to your machine and save it in `C:\Users\username\.ssh\`.
2. Open **Command Prompt** and run:
   bash

   ```
   ssh -p 7822 username@ruachost.com
   ```

   If the key is saved in a different directory, specify the key file path with the `-i` option.

### For macOS/Linux Users:

1. Save the private key in `/home/username/.ssh/`.
2. Open **Terminal** and run:
   bash

   ```
   ssh -p 7822 username@ruachost.com
   ```
3. To avoid typing your passphrase repeatedly, add this to `~/.ssh/config`:
   bash

   ```
   Host *
       AddKeysToAgent yes
   ```

   For macOS, add:
   bash

   ```
   UseKeychain yes
   ```

By following these steps, you can securely access your ruachost account using SSH keys for automated tasks or user file transfers without compromising security.
