---
title: "How to configure additional SSH keys on an instance"
description: "When creating an instance in the OVHcloud Control Panel, you can add only one SSH key for the preconfigured user account. To log on to your instance with other"
url: https://docs.us.ovhcloud.com/en/public-cloud/compute/configuring-additional-ssh-keys
lang: en
---
> For AI agents: the complete documentation index is available at https://docs.us.ovhcloud.com/en/llms.txt, the full documentation bundle is available at https://docs.us.ovhcloud.com/en/llms-full.txt.

# How to configure additional SSH keys on an instance

When creating an instance in the OVHcloud Control Panel, you can add only one SSH key for the preconfigured user account. To log on to your instance with other use accounts, you can create more keys and add them to the instance in a few steps.

**Warning:**

**NOTE:** OVHcloud provides services for which you are responsible for their configuration and management. You are therefore responsible for their proper functioning.\
\
This tutorial is designed to help you as much as possible with common tasks. If you are having difficulty performing these actions, please contact a specialized service provider. OVHcloud cannot provide you with technical support in this regard.

 

## Requirements

- A [Public Cloud instance](https://us.ovhcloud.com/public-cloud/) in your OVHcloud account
- [Administrative access (root) to your instance via SSH](https://docs.us.ovhcloud.com/en/public-cloud/compute/creating-ssh-keys.md)

 

## Instructions

**Note:**

We currently support the following SSH key formats: **RSA**, **ECDSA** and **ED25519**.

Note that the instructions below are for general use, based on an Ubuntu server OS. Some commands may require customization for the distribution or operating system you are using.

### Step 1: Create a new SSH key pair

If necessary, use our [SSH key guide](https://docs.us.ovhcloud.com/en/public-cloud/compute/creating-ssh-keys.md) to create a new SSH key pair.

You can also find information on [managing multiple keys](https://docs.us.ovhcloud.com/en/public-cloud/compute/creating-ssh-keys.md#creating-key-pairs-for-openssh-connections) on your local device if your setup requires it.

 

### Step 2: Configure a new user account

[Connect to your instance](https://docs.us.ovhcloud.com/en/public-cloud/compute/getting-started.md) and use the commands below to create a new user account and `.ssh` folder:

```
sudo adduser user2
```

```
info: Adding user `user2' ...
info: Selecting UID/GID from range 1000 to 59999 ...
info: Adding new group `user2' (1003) ...
info: Adding new user `user2' (1003) with group `user2 (1003)' ...
info: Creating home directory `/home/user2' ...
info: Copying files from `/etc/skel' ...
New password: 
Retype new password:
passwd: password updated successfully
Changing the user information for user2
Enter the new value, or press ENTER for the default
        Full Name []:
        Room Number []:
        Work Phone []: 
        Home Phone []: 
        Other []: 
Is the information correct? [Y/n] y
info: Adding new user `user2' to supplemental / extra groups `users' ...
info: Adding user `user2' to group `users' ...
```

```
sudo mkdir /home/user2/.ssh/
```

Without further steps, the user account `user2` in this example has no elevated permissions. If you need to grant this account `root privileges` on your instance, add it to the `sudo group`:

```
sudo usermod -aG sudo user2
```

You can learn more about user permissions and related topics in our [user account guide](https://docs.us.ovhcloud.com/en/bare-metal-cloud/dedicated-servers/configure-user-accounts-root-access-server.md).

 

### Step 3: Add the public SSH key to your instance

#### Transferring public keys created on systems based on GNU/Linux, MacOS, or BSD

If you have created your SSH key pairs on a GNU/Linux, MacOS or BSD based system, you can use the command `ssh-copy-id` to add the public keys to your server.

The `ssh-copy-id` utility copies public keys to the file `~/.ssh/authorized_keys` on the specified remote server and will automatically create the file in this directory if necessary.

```
ssh-copy-id username@IP_ADDRESS
```

By default, `ssh-copy-id` will try to transfer **all** public keys inside your local user's `~/.ssh` directory. In order to add a single public key, you can specify this key file with the option `-i` followed by the file path:

```
ssh-copy-id -i ~/.ssh/KeyFileName username@IP_ADDRESS
```

Example:

```
ssh-copy-id -i ~/.ssh/myInstance_rsa.pub user2@203.0.113.102
```

You will be prompted for the user's password. If the process was successful, you will receive a message similar to the one below.

```
Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'user@server-ip'"
and check to make sure that only the key(s) you wanted were added.
```

If you receive an error message instead, you can always add your public keys manually by following the steps described below.

As a best practice and for security reasons, a key pair should not be used by multiple users. Since each user on GNU/Linux systems has their own `authorized_keys` file in `~/.ssh/`, you can use the command `ssh-copy-id` as shown above and adapt `KeyFileName` and `user` after you have [created the key pair](https://docs.us.ovhcloud.com/en/public-cloud/compute/creating-ssh-keys.md).

 

#### Adding public keys to the instance manually

[Connect to your instance](https://docs.us.ovhcloud.com/en/public-cloud/compute/getting-started.md) and open the file `authorized_keys` in the personal folder of the new user with your preferred text editor (`nano` is used in this example):

```
sudo nano /home/user2/.ssh/authorized_keys
```

Paste the **public key string** into this file. Save the file and exit the editor.

Reboot your instance (`sudo reboot`) or only restart the OpenSSH service with one of the following commands (the appropriate command may vary depending on your OS):

```
sudo systemctl restart ssh
```

```
sudo systemctl restart sshd
```

The new user can now connect to the instance from the device that stores the corresponding private SSH key:

```
ssh username@IP_ADDRESS
```

Example:

```
ssh user2@203.0.113.102
```

Consult the [SSH key guide](https://docs.us.ovhcloud.com/en/public-cloud/compute/creating-ssh-keys.md) to learn more about using SSH keys with Public Cloud instances.

 

## Go further

[How to create Public Cloud instances](https://docs.us.ovhcloud.com/en/public-cloud/compute/getting-started.md)

[How to replace an SSH key pair on a Public Cloud instance with rescue mode](https://docs.us.ovhcloud.com/en/public-cloud/compute/replacing-lost-ssh-key-pair.md)

Browse all the [Compute guides](https://docs.us.ovhcloud.com/en/public-cloud/compute/landing-page-compute.md).

Browse the rest of the [OVHcloud US documentation](https://docs.us.ovhcloud.com/en/index.md) for guides on our other products and services.

Learn more about [Public Cloud Compute](https://us.ovhcloud.com/public-cloud/compute/) on the OVHcloud US website.
