Keys instead of passwords
An SSH key pair has two halves. The private key stays on your computer and must never be shared. The public key is a single line that you place in the authorized keys file of a server. When you connect, the client proves that it holds the private key without sending it, and the server accepts the connection. Passwords can be guessed and reused. A private key is much harder to steal in a useful form, and it can be protected with a passphrase.
By convention the keys live in the .ssh directory of your home directory. Common names are id_ed25519 for the private key and id_ed25519.pub for the public one. The directory itself must be private, and the private key file must not be readable by other users.
Permissions that ssh checks
The ssh client refuses to use a private key that other users can read, and it warns when the .ssh directory is too open. The usual modes are 700 for the directory and 600 for private files and the config file. Setting them is a standard step.
mkdir -p .ssh
chmod 700 .ssh
ls -ld .sshThe listing shows the directory with the owner-only permissions. In the lab the home directory is /workspace, so .ssh here is /workspace/.ssh, which is the same layout you would use on your own machine.
The config file
The file .ssh/config lets you define a host alias with its real name, user, port, and key. A block begins with a Host line, and the indented lines below it apply to that alias. The first value found for each option wins, which is why general defaults belong at the end, in a block with Host *.
Host devbox
HostName 203.0.113.10
User deploy
Port 22
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yesWith this block, the command ssh devbox connects to 203.0.113.10 as the user deploy, using only the named key. The address shown is a documentation address reserved for examples, so the block is safe to read and copy.
Set IdentitiesOnly yes for each host that has its own key. Without it, the client offers every key in your agent, and a server with a limit on failed attempts can disconnect you before it reaches the right one.
Defaults for every host
A block with Host * applies to every alias that did not match an earlier block. It is the right place for settings you want everywhere, such as keepalive intervals. Because the first match wins for each option, a specific block placed after Host * does not override it, so keep the specific blocks first.
Copying files is a separate step
The next unit covers the programs that copy files over SSH. The config file helps them too, because the alias works in every command that takes a host.
Hands-on: write the alias file
The lab asks you to create a config file with a host alias, set its permissions, and record the aliases you defined. The check reads the file, so the exact text matters. Practice the layout above, with HostName and IdentityFile lines indented under the Host line.