Learn how to configure additional SSH keys for connections to your instance.
When creating an instance, only one SSH key for the initial connection can be configured. In order to grant access to your instance to other users, additional keys can be added by configuring the authorized_keys file.
Requirements
- a Public Cloud instance in your OVHcloud account
- access to the OVHcloud Control Panel
- administrative access (root) to your instance via SSH
Instructions
Creating the SSH key
To create a new SSH key, consult our How to Create and Connect a Public Cloud Instance guide.
Configuring the new user
Connect to your instance with SSH and use the command below to create a new user:
~$ sudo adduser user2
Adding user `user2' ...
Adding new group `user2' (1001) ...
Adding new user `user2' (1001) with group `user2' ...
Creating home directory `/home/user2' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX 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
Open the authorized_keys file in the personal folder of the new user with a text editor:
~$ sudo nano /home/user2/.ssh/authorized_keys
Add the public key created in the first step to the file. Save and close the editor.
If the .ssh folder does not already exist, you can create it with this command:
~$ sudo mkdir /home/user2/.ssh/
You can configure multiple SSH keys by adding them to the authorized_keys files of the corresponding user folders.
From now on, you can log in with the user and the private key configured previously:
~$ ssh user2@instance_IP
Linux b2-7-de1 5.10.0-10-cloud-amd64 #1 SMP Debian 5.10.84-1 (2021-12-08) x86_64
user2@server:~$
Go further
For more information and tutorials, please see our other Public Cloud support guides or explore the guides for other OVHcloud products and services.