
Create an SSH key on Linux
Step by step with ssh-keygen (ECDSA), where keys live, and how to show your public key for GitHub, GCP, and other services.
This walkthrough shows how to create an SSH key pair you can use with GCP, GitHub, internal portals, and other services.
Originally published 16 October 2021; revised for this blog.
Run:
You will be asked for a file path and a passphrase. For the default path and no passphrase in this example, press Enter at each step.
When it finishes, output will include:
The line that says where the .pub file is saved (for example ~/.ssh/id_ecdsa.pub) is the public key path.
You register the public key on the service (GitHub settings, a cloud project, an intranet). Never paste your private key (the file without .pub) into a website.
You will see one line starting with ecdsa-sha2-nistp256 followed by the key body and a trailing comment. Copy the full line when adding the key to a service.
Illustrative example (always generate your own on your machine):
cat output..pub line only).On a new machine, create a new pair or migrate .ssh carefully, with correct permissions (e.g. chmod 600 on private keys).