How to copy the new public key?

0114

To copy the new public key to the target system, you can use the ssh-copy-id command or manually append it to the authorized_keys file. Here are both methods:

Method 1: Using ssh-copy-id

  1. Run the following command:

    ssh-copy-id username@target_host

    Replace username with your username on the target system and target_host with the IP address or hostname of the target system.

  2. Enter your password when prompted. This command will automatically copy your public key to the authorized_keys file on the target system.

Method 2: Manually Copying the Public Key

  1. Display your public key:

    cat ~/.ssh/id_rsa.pub
  2. Copy the output of the public key.

  3. SSH into the target system:

    ssh username@target_host
  4. On the target system, open or create the authorized_keys file:

    mkdir -p ~/.ssh
    nano ~/.ssh/authorized_keys
  5. Paste the public key into the authorized_keys file. Save and exit the editor.

  6. Set the correct permissions for the authorized_keys file:

    chmod 600 ~/.ssh/authorized_keys

After completing these steps, you should be able to SSH into the target system without needing to enter a password.

0 Comments

no data
Be the first to share your comment!