Key based authentication also known as public key authentication allows you to log into a server without having to remember your password or worst needing to write down the password. Most important Public key authentication provides cryptograph strength over the most complex password. It is now more common for users to log into a server using a public key than typing a password.
VPS Cloud+ puts the importance of security before any other operations as such we have strived to make SSH key management as easy as possible to our users while maintaining high-security standards.
Are you new to SSH Keys? Here are a few key concepts
SSH Key pair includes two keys:
A public key: This is the key copy that is shared with trusted parties. With a valid public key, user can encrypt data that can only be decrypted by the corresponding private key. More to come on private key. Worth noting a copy of a public key can be relieved to a third party without compromising the security integrity.
A private key: This is the counterpart of the pubic key. This part of the key pair is kept secret by the SSH user and MUST NOT be distributed. The SSH user with a private key that corresponds to the host public key is allowed SSH access to the host server. Both, private and public keys are generated as a pair on the SSH server at the same time. It is important the SSH user identifies the private key and stores the key in a secured location where only the user with admin privileges can access the private key. For Linux, Windows, and macOS the default location for the public key is in
/home/user/.ssh or simply
~/.ssh. You can specify a location of your choice when generating the SSH Key pair.
Generating SSH Key with OpenSSH
Before we dive into how to generate SSH key pair using OpenSSH let's see what is OpenSSH; by definition, OpenBSD Secure Shell or OpenSSH is a suite of secure networking utilities demons based on the Secure Shell (SSH) protocol, which provides a secure channel over an unsecured network in a client-server architecture and is available in most macOS and Linux distributions. You will need to manually install OpenSSH on Windows 10. OpenSSH generates SSH Key pair using ssh-keygen. The following is an example for generating SSH Key pair using OpenSSH.
First, check if OpenSSH is installed on your machine, you can do this by typing
ssh –v on your terminal. Command not found indicates OpenSSH is not installed on your machine. You will need to install OpenSSH to continue.
Once you have verified OpenSSH is installed on your machine it takes less than a minute to generate SSH key pair. Follow the below simple steps to generate SSH key pair.
On your terminal run commands
Expected terminal output:
Enter file in which to save the key (/Users/vpscloud/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
The key's randomart image is:
|+&@@=. =Oo. |
|B+O+* oB.o |
|.= .o==o= |
| E= +oo. |
| . . ..S |
| o |
The default filename for SSH key pair is id_rsa and id_rsa.pub for private and public keys respectively. Please note if id_rsa file already exists in ~/.ssh/ and you choose not to overwrite the existing file a new filename will be saved in the active directory. The default location for SSH key pair for Linux and macOS is /home/login_user/.ssh/ For Windows the default location is C:\Users\login_user\.ssh\ . Once the SSH key pair is generated and you have located your public key, you can share the public key with the host server or trusted third parties. Typically, this is done by ssh-copy-id utility: ssh-copy-id -i ~/.ssh/ubuntukey.pub user@hostname
SSH Key and VPS Cloud+:
VPS Cloud+ makes managing SSH key hassle free. You can generate SSH key pair by simply running the above command and select “Add new” in the Instance Create section, where you can paste the content of your public key or you can browse your local folders. For more hassle free SSH key management you can choose to use our SSH key pair management system by simply selecting Generate tab on Add SSH Key section and simply enter the name of your key. This will generate an SSH key pair and the private key pem file will download automatically.
As an admin user, run the following command to copy your private SSH key pem into ~/.ssh/id_rsa
Run openssl rsa -in your_download_private_key.pem -out ~/.ssh/id_rsa
You can now use the corresponding public key in the instance you are launching.
Install OpenSSH on Windows 10 1809
If you are running on Windows 10 you will need to install OpenSSH as OpenSSH client is not installed by default.
Follow the below steps to install OpenSSH client for Windows 10 1809. You can also install OpenSSH client through PowerShell. For more details, please visit OpenSSH Client installation
1. Locate Manage Optional Features under Settings --> Apps --> Apps and Features
2. Check if OpenSSH Client is installed. For new installation click on Add a feature
3. Seach for OpenSSH Client and select install
4. On a successful installation of OpenSSH Client you can generate an SSH key pair by following the steps on Generating SSH key pair with OpenSSH.