Skip to content

Instantly share code, notes, and snippets.

@bvlourenco
Last active October 4, 2023 08:27
Show Gist options
  • Save bvlourenco/d169722ae2fa38045655cd76ecea6b33 to your computer and use it in GitHub Desktop.
Save bvlourenco/d169722ae2fa38045655cd76ecea6b33 to your computer and use it in GitHub Desktop.
Create new SSH key for Git/Github

To create an SSH key locally:

cd ~/.ssh

# Creates a new pair of SSH keys using elliptic curve called ed25519
# You will have to prompt the path to save the key and a passphrase
ssh-keygen -t ed25519

# Creates a new file called config that will store information about the key and who will access it
# You can use an editor at your choice
nano config

In config file, write the following content:

Host github.com
HostName github.com
User git
IdentityFile $PATH

$PATH is the path where we saved the key.
For instance, $PATH = ~/.ssh/id_github

Close the file. Fetch the content of the generated public key with the following command:

# Fetch the content of public key generated. id_github is the name of the key
cat $KEYNAME.pub

$KEYNAME is the name of the key.
For instance, $KEYNAME = id_github given the path above in IdentityFile attribute of config file.

In the end, add the public key (it is the output of cat command) here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment