Saturday, 6 June 2026

How to Setup SSH Key Authentication in Linux (Passwordless Login)

 SSH key authentication allows you to log into a remote Linux server without typing a password every time. It is more secure and widely used in DevOps environments.


Step 1: Generate SSH Key Pair

Run this command on your local machine:

ssh-keygen -t rsa -b 4096

Press Enter for all prompts. This will create:

  • Private key: ~/.ssh/id_rsa
  • Public key: ~/.ssh/id_rsa.pub

Step 2: Copy Public Key to Server

Use:

ssh-copy-id user@server_ip

Example:

ssh-copy-id ubuntu@192.168.1.10

Step 3: Test SSH Login

ssh user@server_ip

You should now login without password.


Common Issue

If login still asks password, check:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Conclusion

SSH key authentication is the foundation of secure Linux server access and DevOps automation.

No comments:

Post a Comment