How to add public key to authorized_keys?

0213

To add your public key to the authorized_keys file on the target system, follow these steps:

  1. Create the .ssh directory (if it doesn't already exist):

    mkdir -p ~/.ssh
  2. Append your public key to the authorized_keys file:

    cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

    This command assumes your public key is located at ~/.ssh/id_rsa.pub. Adjust the path if your key is stored elsewhere.

  3. Verify the contents of the authorized_keys file:

    cat ~/.ssh/authorized_keys

    You should see your public key listed.

  4. Set the correct permissions for the authorized_keys file:

    chmod 600 ~/.ssh/authorized_keys

    This command ensures that only the owner can read and write to the file, which is a security requirement.

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!