You need to clone in ssh not in https.
$ ssh-keygen -t ed25519 -C "your_email@example.com"
Add content of ~/.ssh/id_rsa.pub
to your ssh keys on github.com.
If you need to have separate keys for different hosts, you can use this script:
#!/usr/bin/env bash
if [ $# -lt 2 ]; then
echo "Provide email and hostname"
exit 1
fi
email="$1"
hostname="$2"
keypath="$HOME/.ssh/${hostname}_rsa"
ssh-keygen -t ed25519 -C $email -f $keypath
if [ ! $? -eq 0 ]; then
echo "Error when running ssh-keygen"
exit 1
fi
exit 0
cat >> $HOME/.ssh/config <<EOF
Host $hostname
User git
IdentitiesOnly yes
IdentityFile $keypath
EOF
and run it like
bash generate_ssh.sh your_email@example.com github.com
Change your remote url
git remote set-url origin git@github.com:user/foo.git
(or just edit .git/config
)
Add content of ~/.ssh/github.com_rsa.pub
to your ssh keys on github.com
Check connection
ssh -T git@github.com