Setting Up SSH Keys on Debian/Ubuntu

SSH keys provide a secure way to log in to your Linux server without using a password.

Generate SSH Key Pair

  1. Open terminal
  2. Run this command:
    ssh-keygen -t ed25519 -C "your_email@example.com"
  3. Press Enter to save the key in the default location
  4. Enter a passphrase (recommended) or leave empty

Copy Public Key to Server

Use either method:

Method 1: ssh-copy-id

ssh-copy-id username@server_ip

Method 2: Manual copy

  1. View your public key:
    cat ~/.ssh/id_ed25519.pub
  2. Connect to your server:
    ssh username@server_ip
  3. Create SSH directory:
    mkdir -p ~/.ssh
    chmod 700 ~/.ssh
  4. Add your key:
    echo "public_key_string" >> ~/.ssh/authorized_keys
    chmod 600 ~/.ssh/authorized_keys

Test Connection

ssh username@server_ip

You should connect without needing a password.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Mastering UFW: A Comprehensive Guide for Debian, Ubuntu, and AlmaLinux

The Uncomplicated Firewall (UFW) offers a user-friendly interface for managing iptables firewall...

Setting Up WireGuard on Debian/Ubuntu for Linux VPS (KVM)

WireGuard is a modern VPN (Virtual Private Network) software that offers state-of-the-art...

Fixing the high server load and memory & CPU consumption of clamd (ClamAV)

Optimizing ClamAV on DirectAdmin Servers If your DirectAdmin servers are experiencing high load...

Firewalling with Firewalld

Firewalld Firewalld is a higher-level implementation of Netfilter, offering a more user-friendly...

File & folder permissions

Understanding and Managing File Permissions on Your Server File permissions are a crucial aspect...