SSH 安装与基础配置(Ubuntu/Debian)

1. Install SSH

Most Linux distributions already include OpenSSH. If not, install it:

sudo apt install openssh-server

Check service status:

sudo systemctl status ssh

Restart if needed:

sudo systemctl restart ssh

2. Configure SSH

Before anything else, ensure security groups / firewall allow TCP port 22.

You can authenticate with:

  • Password login
  • SSH key login (recommended)

After generating a key pair, files are usually:

~/.ssh/id_ed25519
~/.ssh/id_ed25519.pub
  • Private key: keep secret.
  • Public key: upload to server.

Append public keys to ~/.ssh/authorized_keys on the server (one key per line):

ssh-ed25519 AAAAC3... user1@example.com
ssh-ed25519 AAAAC3... user2@example.com

3. Connect to Remote Server

ssh user@your-server-ip

[Image omitted: image.png | source: ../assets/image_1731426731226_0.png]