In Clouding, an encoded PEM private key is automatically generated and assigned to the servers created in your account by default. By using these keys, it is not necessary to authenticate with the operating system user’s password to connect via SSH.
You can add more keys in the My SSH keys tab and link them during server creation to use them. To download them, simply go to the same section and, under Actions for the private SSH keys (PEM), click the download icon to obtain the key:
Connect with the private key via SSH
An SSH client is installed by default on Linux and MacOS. Therefore, you can specify the use of the downloaded key as follows:
# ssh root@server_IP_address -i /path/example/default.pemYou will access the server directly without needing to enter a password, but Windows does not include an SSH client by default, so you will need to install one.
Install the OpenSSH Client feature on Windows
You can run the following command in PowerShell with administrator privileges to install the client:
# Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
You can also do this from Windows’ own “Add optional features” section. Once installed, open a command prompt (CMD) or PowerShell to use the OpenSSH client:
# ssh root@server_IP_address -i "Downloads\default.pem"
In the Add the key to the SSH agent (optional) section, you can also use it in Windows and add the key so that you do not have to specify it repeatedly.
Another alternative is to use PuTTy on Windows. The article How to access SSH from Windows with PuTTy and PuTTygen explains how to use the PuTTy client with the key.
Add the key to the SSH agent (optional)
If you want to implement it and/or avoid having to specify it when connecting to the server, you can store it for the SSH client by using the option to add it:
# ssh-add key.pemIn Windows, the SSH agent is disabled by default, and the following message will appear when you try to use it:
Error connecting to agent: No such file or directory
Therefore, you will need to start it. You can check the agent’s status from PowerShell with administrator privileges by running the following:
# Get-Service | ?{$_.Name -like '*ssh-agent*'} | select -Property Name, StartType, Status
It will appear as stopped. To start it, change the service to manual mode and start it:
# Set-Service -Name ssh-agent -StartupType Automatic ; Start-Service ssh-agent
In Linux, the following message will appear if the agent is not enabled:
Could not open a connection to your authentication agent.
To enable the agent in Linux, run the following command (replace bash with your shell):
# exec ssh-agent bash
When adding the key with the agent enabled, the following may occur:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0744 for 'key.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
You will need to change the permissions so that only the user has access:
# chmod 600 key.pem
Afterward, you will be able to add the key:
# ssh-add key.pemAdditional information
To create individual keys for users of a server or client, you can review the following article on Creating keys with ssh-keygen.
We hope this article has been helpful. If you still have questions about this or any other issue related to your servers in Clouding, write to us at soporte@clouding.io. We’re here to help! 😉