Stay up to date!

Success! Now Check Your Email

To complete Subscribe, click the confirmation link in your inbox. If it doesn’t arrive within 3 minutes, check your spam folder.

Ok, Thanks
🔑 How SSH Keys Work and How We Uploaded Them 2 min read
Tech

🔑 How SSH Keys Work and How We Uploaded Them

By Luis Garcia
🔑 How SSH Keys Work and How We Uploaded Them Post image

#kubernetes #Tech

When working with multiple servers, repeatedly entering passwords can be tedious and time-consuming. SSH keys provide a secure and convenient way to log in to servers without typing a password each time.

Here’s a quick overview of how they work and the steps we used to set them up.


🔑 What Are SSH Keys?

SSH (Secure Shell) keys are cryptographic key pairs used for authenticating users to remote systems. Each key pair consists of:

  • Private key: Kept secret on your local machine.
  • Public key: Shared with the remote server.

When you connect via SSH, the server uses the public key to verify that you have the corresponding private key. If the keys match, you gain access — no password required.

Benefits:

  • Stronger security than passwords
  • Automation-friendly for scripts and tools
  • Eliminates repetitive password entry

🛠 Steps to Upload SSH Keys to Servers

Here’s how we set up SSH key-based login from Windows PowerShell to Ubuntu servers:

1. Generate an SSH Key Pair

ssh-keygen -t ed25519 -C "[email protected]"
  • This creates 'id_ed25519' (private) and 'id_ed25519.pub' (public) in C:\Users<YourUser>.ssh.
  • Pressed Enter to accept defaults.

2. Copy the Public Key to the Server

Using PowerShell, we can then send the key to the server:

scp "$env:USERPROFILE\.ssh\id_ed25519.pub" [email protected]:/tmp/id_ed25519.pub
  • Replace the IP for each server

3. Install the Key on the Server

Log into the server and append the key to authorized_keys:

mkdir -p ~/.ssh
cat /tmp/id_ed25519.pub >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
rm /tmp/id_ed25519.pub
  • Create the .ssh directory if it didn’t exist
  • Set proper permissions
  • Remove the temporary uploaded file

âš¡ The One-Liner Option (No Manual Steps)

You can also upload your public key directly in one command — no manual server login required:

type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh [email protected] "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && chmod 700 ~/.ssh"

Here’s what happens:

  • type outputs your public key’s contents.
  • It’s piped (|) into ssh, which connects to the server.
  • The remote command creates the .ssh folder (if needed), appends the key to authorized_keys, and sets correct permissions.

Repeat this command for each of your servers (_10.0.0.11, 10.0.0.12_) .etc — all from your Windows terminal.


4. Test the Connection

Now test passwordless SSH:

ssh [email protected]

If everything’s configured correctly, you’ll connect instantly without a password prompt.


✅ Summary

SSH keys are a secure and convenient way to access servers. Once set up, they allow automated logins, which is especially helpful when managing multiple servers, as we did for our Kubernetes nodes.

By generating keys, copying the public key to each server, and configuring the server’s authorized_keys, we created a passwordless, secure workflow for logging in from Windows.


This approach is faster, more secure, and ideal for automation compared to typing passwords manually.