If you are a new user of DigitalOcean, you may want to create an SSH key to access your droplet. You can do this by following these steps:
1. Visit the DigitalOcean Account page.
2. Click on the ” Keys” link in the top right corner.
3. Click on the “Add new key” button.
4. Provide a name for your key, and click on the “Generate” button.
5. Copy the key’s public key to your clipboard.
6. Go to your droplet’s root directory (i.e. /home/ on a droplet with 3GB of disk space).
7. Create a file called .ssh/authorized_keys with the following contents:
- ssh-rsa [key] [user]@[host]
The [key] part of the string is the actual RSA key, which is a long string of characters that represents the key. It is typically encoded in base64 and begins with AAAAB3NzaC1yc2E.
The [user] and [host] parts of the string are optional and can be used to identify the user and host associated with the key. These values can be any string, but it is common to use the username and hostname of the machine where the key was generated.
Here is an example of a valid RSA public key:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9… john@example.com
8. Put the public key you copied earlier in this file. Save the file. Restart your droplet.
9. When you log in, your new key will be automatically loaded.