A Guide to Server Security with Passwordless Authentication

A Guide to Server Security with Passwordless Authentication

Passwordless Authentication Between Servers: A Step Toward DevOps Mastery

Embarking on the DevOps journey means diving into automation, security, and efficiency—principles that drive the seamless functioning of modern IT infrastructure. One of the core skills that DevOps engineers leverage every day is passwordless SSH authentication. By automating secure, password-free connections between servers, we open the door to countless automations and streamline deployments across multiple environments. This guide isn’t just about achieving a technical outcome; it’s about adopting a DevOps mindset of efficiency and continual growth.


Why Passwordless Authentication?

The ability to connect servers without entering a password is key to creating a secure, automated, and efficient workflow. This setup lays the foundation for automated deployments, server management, and cross-server communication, freeing up time to focus on higher-impact tasks. In this guide, we'll implement passwordless authentication between two EC2 instances—one of the countless small but powerful skills on the path to DevOps mastery.


Prerequisites

Before diving in, make sure you have:

  • Two or more AWS EC2 instances to work with

  • Basic SSH and terminal command skills

  • Sudo access on each instance

This task may seem straightforward, but it’s a building block for more complex DevOps skills. Embrace each step, knowing that small tasks like these compound to make a real difference over time.


Steps to Implement Passwordless Authentication

Step 1: Launch and Connect to EC2 Instances

Start by creating two EC2 instances on AWS. Each server you work with will help build your familiarity with cloud infrastructure and how different environments communicate. Connect to each instance via SSH:

ssh -i "your-key.pem" ubuntu@<private_ip_of_your_instance>

Step 2: Update and Upgrade Both Servers

In DevOps, consistency matters. Ensuring your servers are up-to-date prevents compatibility issues and keeps the environment clean and predictable. Run the following on each instance:

sudo apt update && sudo apt upgrade

Step 3: Generate SSH Keys on the Target Server

Log into the target server—the server you’ll connect to without a password. By generating a unique SSH key, you’re setting up a secure, cryptographic handshake between servers. Run:

ssh-keygen

This will create a public key (id_ed25519.pub) and a private key (id_ed25519) in the ~/.ssh directory. Think of these keys as your servers’ secret handshake.

Step 4: Copy the Public Key from the Target Server

Copy the public key to be added to the source server. This key will be your link to passwordless access:

cat ~/.ssh/id_ed25519.pub

Step 5: Add the Public Key to the Source Server’s authorized_keys

Now, log in to the source server. Open the authorized_keys file, which lists all approved public keys, giving you seamless access between the servers:

vim ~/.ssh/authorized_keys

Step 6: Append the Public Key to authorized_keys

Paste the copied public key from the target server at the end of this file. Save and close the file. You’re now one step closer to establishing a secure, passwordless connection.

Step 7: Test the Passwordless Connection

Testing is essential in DevOps. Run this command on the source server to try connecting to the target server without a password:

ssh <private_ip_of_target_server>

If everything is configured correctly, you’ll be logged in without a password prompt! This confirmation might feel small, but it’s a powerful step forward in your DevOps journey.

Step 8: Verify the Setup

To solidify your understanding, create a directory on the target server and confirm it’s visible from the source server.

  1. On the target server:

     mkdir amitabh
    

  2. On the source server, SSH into the target server and list the contents:

     ls
    

  3. Seeing amitabh confirms your setup is working perfectly.


Final Thoughts: DevOps is About Mindset and Skills

Passwordless authentication is a single skill, but it’s a cornerstone of the DevOps mindset. By automating and securing connections between servers, you’re learning the power of simplicity and efficiency. Each small step, task, and problem solved builds your confidence and capability.

Keep pushing forward, knowing that mastering these fundamentals brings you closer to a full grasp of DevOps. Embrace each moment, and remember: every command executed, every connection made, and every problem solved is part of your journey to becoming a DevOps professional.