What is SSH?
A protocol (and command) that encrypts communication for logging in to another computer over a network and running commands there. The server listens on TCP port 22 by default. Besides passwords, public-key authentication is widely used for authentication: the public key corresponding to the private key at hand is registered in ~/.ssh/authorized_keys on the server. Over the same connection, files can be transferred with scp or rsync, and ports can be forwarded.
Japanese name: SSH
SSH appears in 3 practice questions across 2 topics, including Linux and Command-Line Basics, Computer Networking Basics.
Field: Linux and Command-Line Basics
How public-key authentication works
A pair of a private key and a public key is created with ssh-keygen, and only the public key (the .pub file) is registered in authorized_keys on the server. When connecting, the client makes a signature with the private key and presents it to the server, which checks it with the registered public key, so the private key itself never travels over the network. The private key is protected with a passphrase, and leaving it with ssh-agent reduces the effort of entering it at every connection.
Verifying the server
On the first connection, ssh shows the fingerprint of the server's host key and, if accepted, records it in ~/.ssh/known_hosts. From then on, if a key different from the record is presented, it warns and stops, so an impersonating server can be noticed. If the warning appears without a reason such as the server having been replaced, the connection must not be continued.
FAQ
I cannot connect, and "Permission denied (publickey)" is shown. What should I check?
Check that the public key corresponding to the private key in use is registered in ~/.ssh/authorized_keys on the server, and that the user name is correct. If the permissions of ~/.ssh or authorized_keys on the server are too loose (writable by others), the key may not be used for safety, so set ~/.ssh to 700 and authorized_keys to 600, for example. With ssh -v, it shows which keys were tried.
How do I choose between scp and rsync?
Both can transfer files over ssh. scp suits simple copies, while rsync sends only the differences from the destination, so it is efficient for repeatedly synchronizing large directories or resuming interrupted transfers. Used as rsync -av --delete, it makes the destination match the source, but --delete removes files that exist only at the destination, so care is needed.