Free lesson

SSH keys and host identity

SSH keys and host identity — Prepare a Linux VPS for AI projects. Keep the private key on the client; Verify the host fingerprint; Prove key authentication. Practical assignment: Practice: SSH keys and host identity.

Demo edition. The materials are undergoing editorial review.

Topics covered

  • Keep the private key on the client
  • Verify the host fingerprint
  • Prove key authentication

Keep the private key on the client

SSH uses a key pair: the server receives the public key and the client proves possession of its private counterpart. Create a separate Ed25519 lab key with a new filename and passphrase. Never overwrite an existing identity. The example deliberately chooses a course-specific path. Only the file ending in .pub goes to the server; the private file is not an attachment for an administrator. Keep an encrypted recovery copy outside the VPS so losing the client does not remove your only identity.

ssh-keygen -t ed25519 -f ~/.ssh/ai_lab_ed25519 -C ai-lab

Verify the host fingerprint

User keys and host keys solve different problems. Your key authenticates you; the host key identifies the destination. On the first connection, compare the displayed SHA256 fingerprint with an independent trusted channel such as the provider console. A confirmation prompt is not proof that the address is safe. If the fingerprint changes, investigate a rebuild or reassigned address. Do not remove known_hosts entries merely to silence the warning. Confirm the new identity independently before changing your local record.

Prove key authentication

This lesson tests the existing administrator through whom you obtained lab access. The new operator account is created only in lesson03. Through a trusted console, append only the new .pub key to that existing account’s authorized_keys; never copy the private key. Replace existing_admin and lab.example with your verified account and lab address. Keep the original session open and create a second connection with the explicit identity and server-password fallback disabled. A local key-passphrase prompt can still be expected. On rejection, check account existence, home, ownership and permissions of .ssh and authorized_keys. Do not disable server password access before a successful fresh connection, and never report success from an unexecuted test.

ssh -i ~/.ssh/ai_lab_ed25519 -o IdentitiesOnly=yes -o PasswordAuthentication=no -o KbdInteractiveAuthentication=no existing_admin@lab.example

Practical assignment

Practice: SSH keys and host identity

Continue to learning

Course outline

  1. Inventory and recovery access
  2. SSH keys and host identity
  3. Separate operator and permissions
  4. Firewall without losing SSH
  5. Updates and controlled restarts
  6. SSH configuration and VPS acceptance