How to create and copy an ssh key

In order to create and copy an ssh key, we must follow these steps:

Required data

  • username = user name at the machine where the ssh key will be set
  • userpass  = password at the machine where the ssh key will be copied
  • target machine = machine at which the ssh key will be copied to

Sample data

  • username = abernal
  • userpass  = password
  • target machine = target.machine.com

Process

1. Type the next command at the console

$ ssh-keygen -t rsa

2. Store the keys and passphrase (by default : Enter)

Enter file in which to save the key (/home/demo/.ssh/id_rsa):

3. Enter passphrase and confirm (empty for no passphrase):

Enter some passphrase (empty for no passphrase):
Enter some passphrase again :

4. Copy the public key

$ ssh-copy-id [email protected]