Basic
For encryption purpose, now ed25519 is preferred over RSA.
From Google:
Ed25519 is generally preferred over RSA for SSH key pairs due to its faster performance, more secure algorithm, and more compact key size
ssh key check:
# Check whether you have a ed25519 key
ls ~/.ssh/id_ed25519.pub
ssh keygen:
# Generate a new ed25519 key
ssh-keygen -t ed25519
# Optional
# ssh-keygen -t ed25519 -C "your_email@example.com"
Then the public key can be found in ~/.ssh/id_ed25519.pub
, you can cat
it then use it on github.com to use git with github ssh authentication.
fatal: Could not read from remote repository
Example error message:
Cloning into 'some-private-repo'...
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
This is likely because your ssh configuration does not work with github.com by default (likely because you are using a corp laptop.)
Fix without config change
git with a specific credential: (Assume you already have an ed25519 key generated, if not you may want to generate it first, cause you probably don’t want to use your corp key for github.com)
git -c "core.sshCommand=ssh -i ~/.ssh/id_ed25519" clone git@github.com:your-name/your-private-repo.git
Fix with config change
Add this to your ~/.ssh/config
( ssh config)
(Assume you already have an ed25519 key generated, if not you may want to generate it first, cause you probably don’t want to use your corp key for github.com)
Host github.com
HostName github.com
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
Questions
Is this related to ssh-add -l
output and do we need to run ssh-add ~/.ssh/id_ed25519
first?