How Do I Generate RSA SSH Keys ?

Here are the general steps to create an SSH key and deploy it to a remote server:


1. Open your terminal or command prompt and run the command to generate a new SSH key:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

2. You'll be prompted to enter a file name for the key pair and a passphrase. You can accept the default file name or enter a new one, and optionally enter a passphrase to add an extra layer of security.

3. Once you've entered a file name and passphrase, the `ssh-keygen` command will generate a public and private key pair in your home directory (by default, in `~/.ssh/`). The public key will be saved in a file with a `.pub` extension, while the private key will have no extension.

4. Next, you need to copy the public key to the remote server. You can use the `ssh-copy-id` command for this, like so:

ssh-copy-id username@remote.server.ip.address

Replace `username` with your username on the remote server, and `remote.server.ip.address` with the IP address or domain name of the remote server.

5. If the `ssh-copy-id` command is successful, it will prompt you for your remote server password and then copy your public key to the appropriate location on the server.

6. Finally, you can test the SSH connection to the remote server using the `ssh` command:

ssh username@remote.server.ip.address

This should open an SSH session to the remote server, using your private key for authentication. If everything is working correctly, you should be able to access the remote server without entering your password.

Here's a breakdown of each option in the `ssh-keygen -t rsa -b 4096 -C "your_email@example.com"` command:

- `ssh-keygen`: This is the command to generate an SSH key pair.

- `-t rsa`: This option specifies the type of key to generate. In this case, we're generating an RSA key pair. RSA is a widely used algorithm for public key cryptography and is the default type of key generated by `ssh-keygen`.

- `-b 4096`: This option specifies the key size in bits. In this case, we're generating a key that is 4096 bits long. Longer keys are generally considered more secure, as they are harder to crack using brute force attacks.

- `-C "your_email@example.com"`: This option adds a comment to the key. The comment can be any text you like, but it is typically used to identify the key owner or provide some context for the key. In this case, we're using the comment to specify the email address associated with the key owner.


So, when you run the `ssh-keygen -t rsa -b 4096 -C "your_email@example.com"` command, it generates an RSA key pair with a key size of 4096 bits and adds a comment to the public key indicating the email address of the key owner. The private key is saved to a file in your local `.ssh` directory, while the public key is saved to a file with the same name as the private key, but with a `.pub` extension.

More about : SSH-KEYGEN , SSH-COPY-ID , RSA , DSA & ECDSA