Rate This Document
Findability
Accuracy
Completeness
Readability

Configuring SSH Key-based Authentication

Configuring Public and Private Keys on Linux

  1. Use an SSH tool to remotely log in to the Linux CLI as the OS user.
  2. Create a public-private key pair.
    1
    ssh-keygen -t rsa -b 4096
    

    During the process, perform the following operations:

    • (Optional) Enter the key file names. By default, the id_rsa file (private key file) and id_rsa.pub file (public key file) are saved in the /userhome/.ssh directory.
    • (Optional) Set the password of the key.

    The following information is displayed:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    Generating public/private rsa key pair.
    Enter file in which to save the key (/userhome/.ssh/id_rsa):
    /root/.ssh/id_rsa already exists.
    Overwrite (y/n)? y
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /userhome/.ssh/id_rsa.
    Your public key has been saved in /userhome/.ssh/id_rsa.pub.
    The key fingerprint is:
    SHA256:g8T/XaRUqANpuIjxnI34In89+R68QckZPw7eyEaCU+o root@host11
    The key's randomart image is:
    +---[RSA 4096]----+
    |       . .   ..  |
    |  .  .. +   ..   |
    |   * =+o.. .. .  |
    |  o *=o+ =o. o   |
    |   .+ o S o.. .  |
    |. .... B B o .   |
    | o .E. .O + .    |
    |  . . +. +       |
    |   .   ++        |
    +----[SHA256]-----+
    
  3. Upload the public key file to the node server.
    1
    ssh-copy-id -i /userhome/.ssh/id_rsa.pub root@Server IP
    
    • /userhome/.ssh/id_rsa.pub is the generated public key file. Replace /userhome/ (/root/ for the root user and /home/Common_user_name/ for a common user) with the actual file name.
    • Server IP indicates the node server IP address. Replace it with the actual IP address.

    During the process, enter the password of the node server user.