End the session with exit, logout, or Ctrl+d.First connection to a host? SSH shows its key fingerprint and stores it in ~/.ssh/known_hosts. A sudden "host key changed" warning later means the server was reinstalled, or someone is intercepting the connection.If a session hangs (network drop), type Enter ~ . to force-close it.
Generate a key pair; ed25519 is the modern default (use -t rsa -b 4096 only when a legacy server requires RSA). The private key stays on your machine, the public key goes to servers.
Connection settings live in ~/.ssh/config, one block per host. After that, ssh myserver replaces the whole user/host/port/key incantation, and tab completion picks up the alias.
$ Host myserver HostName server.example.com User admin Port 2222 IdentityFile ~/.ssh/id_ed25519
scp copies files and directories (-r); rsync does the same but resumes and transfers only differences, which makes it better for anything large or repeated.
-L makes a remote service reachable locally: the example exposes the database running on the server's localhost:5432 at your own localhost:5432. -N opens the tunnel without starting a shell.
Send keep-alive packets so idle connections survive NAT timeouts; set it per host or globally in ~/.ssh/config.
$ Host * ServerAliveInterval 60
For work that must survive a disconnect, run tmux on the server: reattach after reconnecting and your programs are still running (see the Tmux basics page).