SSH keys is a commonly used method to connect securely to a remote machine.
They're based on the SSH cryptographic network protocol, which is responsible for the encryption of the information stream between you and the remote machine. Ultimately, using SSH keys, you can connect to your VM without even entering a password and it's much more securely too.
SSH keys come in pairs. There is a private key that is safely stored on a local machine of the user. And a public key that is stored on any remote machine the user wants to connect to. So whenever a user initiates an SSH connection with a remote machine, SSH first checks if the user has a private key that matches any of the public keys on the remote machine. If there is a match it will connect directly, otherwise it prompts the user for a password.
Creating an SSH key pair in Linux or Mac
SSH key pairs are how you login to your instance after it's launched. SSH key pairs can be generated with the ssh-keygen command:
ssh-keygen -t rsa -f cloud.pem
Note: This command will ask for a passphrase, either you enter one, or you can just skip it (we recommend using a passphrase). After this hit enter to generate the key.
Your computer will now generate a pair of keys: A private key (cloud.key), and a public key (cloud.key.pub). Never share the 'private key' with anyone! Of course you're able to share the 'public key'. Paste the contents of the public key in the dialogue window when importing a key pair via your Cloud dashboard.
In order to connect to your instance with the SSH key you can use this command in your terminal:
ssh -i cloud.pem <username>@<instance_ip>
Creating a SSH key in Windows
- Open the PuTTYgen program. It will be installed together with the Putty SSH client which you can get from the Putty website
- In “Type of key to generate”, select SSH-2 RSA.
- Click the Generate button and wait for the SSH key to be generated
- Type a passphrase in the Key passphrase field, and in the confirm passphrase field. You can use a key without a passphrase, but this is not recommended!
- Click the Save private key button to save the private key. (you'll need it later on to connect to your instance)
- Right-click in the text field labeled “Public key for pasting into OpenSSH authorized_keys file” and choose "Select All and Copy it".
- Now you can paste the public key for your Cloud in our dashboard
For information about using SSH in Windows, please read the article Access via SSH
Comments
0 comments
Article is closed for comments.