Saturday, 9 August 2025

Linux - Password less SSH Login

In this blog I will show how to enable a password less SSH access, I will use SSH key-based authentication. This method uses a public/private key pair to authenticate without needing a password.

1. Generate SSH Key Pair on Your Local Machine(Node A)

(Node A) ssh-keygen -t rsa

It will ask two prompts as below - if you do not want to change default values which is empty password simply hit enter twice.

  • Press Enter to accept the default location (~/.ssh/id_rsa)
  • Leave the passphrase empty for true password less login

 2. Copy the Public Key to the Remote Server(Node B)

ssh-copy-id username@nodeb

  • This appends your public key to the remote server’s ~/.ssh/authorized_keys
  • You’ll be prompted for the remote user’s password once

If ssh-copy-id command isn’t installed , use:

cat ~/.ssh/id_rsa.pub | ssh username@nodeb "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

 3. Set Correct Permissions on Remote Server

ssh username@nodeb "chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys"

 4. Test Passwordless Login

ssh username@nodeb

You should now log in without being prompted for a password.

No comments:

Post a Comment