Make ~/.ssh/id_ed25519 readable and writable only by its owner.
Which command is appropriate?
chmod 600 grants owner read/write and no group or other permissions to a private key.
Detailed explanation
chmod 644 ~/.ssh/id_ed25519Incorrect. 644 lets group and other users read the private key.
chmod 755 ~/.ssh/id_ed25519Incorrect. 755 grants broad read and execute permissions.
chmod 600 ~/.ssh/id_ed25519Correct. 600 permits only owner read/write.
chmod 400 ~/.ssh/id_ed25519.pubIncorrect. It targets the public key and changes neither the private key nor its required mode.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); printf 'private' > "$tmp/id_ed25519"; chmod 600 "$tmp/id_ed25519"; stat -c '%a' "$tmp/id_ed25519"; rm -rf "$tmp"Expected result
600Key points
- Private key
- chmod 600
- Different from public key
Notes
- Environment: GNU coreutils / 一時ディレクトリ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Host key
A server identity key used by SSH clients to detect a changed endpoint.
User key
A key pair used to authenticate a user to an SSH server.
Port forwarding
An SSH tunnel that carries traffic between a local, remote, or dynamic endpoint.