You need to clone in ssh not in https.
For that you need to set your ssh keys. I have prepared this little script that automates this:
#!/usr/bin/env bash
email="$1"
hostname="$2"
hostalias="$hostname"
keypath="$HOME/.ssh/${hostname}_rsa"
ssh-keygen -t rsa -C $email -f $keypath
if [ $? -eq 0 ]; then
cat >> ~/.ssh/config <<EOF
Host $hostalias
Hostname $hostname *.$hostname
User git
IdentitiesOnly yes
IdentityFile $keypath
EOF
fi
and run it like
bash script.sh [email protected] github.com
Change your remote url
git remote set-url origin [email protected]:user/foo.git
Add content of ~/.ssh/github.com_rsa.pub
to your ssh keys on github.com
Check connection
ssh -T [email protected]