Pcornel
Linux

SSH

Cheat sheet · https://pcornel.dk/topic.php?topic=359

Back to the Topic

Answer

SSH gives encrypted remote shell access, file transfer and tunnelling. On Linux the server is OpenSSH's sshd and the client is ssh, authenticating with keys (preferred) or passwords.

Remember

Use key authentication, disable password and root login on internet-facing servers, and keep the server config valid (sshd -t) before restarting. ssh -v and the server journal together show where a login fails.

First checks

  • ssh -v user@host — client-side connection and authentication steps
  • journalctl -u ssh -u sshd -e — server log
  • sshd -T — effective server settings
  • ss -ltnp | grep :22 — sshd listening

Commands

ssh-keygen
Generate, inspect, convert and manage SSH public/private key material and known-host keys.
sshd -T
Read current SSH state for a bounded verification step.

Verify in this order

TCP 22 → protocol and key exchange → host key verified → user authenticated (key/password) → session

Where it usually breaks

First mismatch in link/interface → address/namespace → route/neighbor → firewall/policy → socket/daemon → DNS/TLS/SSH/application peer path; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=359

Confirmation

Confirm action

Continue?