LinuxTutorial2 min read

How to Set Up SSH on Linux in 2026

Install OpenSSH, connect to a remote server, set up key-based authentication, and harden your SSH config — a complete beginner guide.

Developer terminal on a laptop in low light

What Is SSH?

SSH (Secure Shell) lets you log into a remote Linux machine and run commands over an encrypted connection. It is the standard way to manage servers and is built into every Linux distribution.

Step 1 — Install the SSH Server

To allow incoming SSH connections on a machine, install openssh-server:

# Ubuntu / Debian
sudo apt install openssh-server -y

# Fedora
sudo dnf install openssh-server -y

Start and enable it so it runs on every boot:

sudo systemctl enable --now ssh

Step 2 — Connect from Another Machine

From your local terminal (or WSL on Windows), connect with:

ssh username@server-ip-address

For example: ssh alice@192.168.1.50. Type yes to accept the host fingerprint on first connection, then enter your password.

Step 3 — Set Up Key Authentication (No More Passwords)

SSH keys are more secure than passwords and much more convenient. On your local machine, generate a key pair:

ssh-keygen -t ed25519 -C "your@email.com"

Press Enter to accept the default save location (~/.ssh/id_ed25519). Add a passphrase for extra security.

Copy the public key to the server:

ssh-copy-id username@server-ip-address

Now you can log in without a password. You will only be prompted for your key passphrase (once, if you use ssh-agent).

Step 4 — Useful SSH Config

Create or edit ~/.ssh/config on your local machine to save connection shortcuts:

Host myserver
    HostName 192.168.1.50
    User alice
    IdentityFile ~/.ssh/id_ed25519

Now you can connect with just: ssh myserver

Basic Hardening Tips

  • Disable password login after setting up keys: set PasswordAuthentication no in /etc/ssh/sshd_config, then sudo systemctl restart ssh
  • Change the default port from 22 to reduce automated scans (optional)
  • Use AllowUsers alice in sshd_config to restrict which accounts can connect

Quick Reference

  • sudo apt install openssh-server — install SSH server
  • ssh-keygen -t ed25519 — generate key pair
  • ssh-copy-id user@host — install public key on server
  • ~/.ssh/config — save connection shortcuts