xxxxxxxxxx
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
xxxxxxxxxx
# 1/ check for previous keys (should not exists before the first time)
cd ~/.ssh #check for already existing pair of id_x and id_x.pub (id_rsa/id_edxxx/ )
# 2/ generate keys (if you dont have any) - pick one
#rsa
ssh-keygen -o
#ed algorithm (recommended)
ssh-keygen -t ed25519 -C you@mail.com
# 3/ add the key to the shh-agent
eval "$(ssh-agent -s)" #if the agent is running, it should return something like Agent pid 18544
sh-add ~/.ssh/id_ed25519 #or: ssh-add ~/.ssh/id_rsa
# 4/ copy the public key
cat ~/.ssh/id_ed25519.pub #or: cat ~/.ssh/id_rsa.pub
# copy all: ssh-ed25510...... you@mail.com or ssh-rsa....... you@mail.com
# 5/ past it to the github
# login - profile prefferences - ssh and gpg keys - new SSH key and paste 4/
# 6/ verify
ssh -v git@github.com
# if you got the following error:
# The authenticity of host 'github.com (ip)' can't be established.
# execute the following command and try again:
ssh-keyscan github.com >> ~/.ssh/known_hosts
xxxxxxxxxx
export GIT_SSH_COMMAND='ssh -o IdentityFile=~/.ssh/my_passkey -o IdentitiesOnly=yes'
git clone git@github.com:GITUSER/GITREPONAME.git
xxxxxxxxxx
# on ubuntu you don't need to use `eval $(ssh-agent -s)` anymore
# just generate the key and put it into ~/.ssh
# copy the .pub key to github and you should be good to go
ssh-keygen -t ed25519 -C your@git.email.here
cat ~/.ssh/id_ed25519.pub # if you saved it somewhere else, change this
# copy the output then go to github > settings > ssh and gpg keys > new ssh key
# paste the output there and save.
# it should work now, if it doesn't and says you don't have permissions,
# double check it and if all else fails:
# add `eval $(ssh-agent -s)` to /etc/profile or ~/.bashrc
# From SO:
# > /etc/profile is global for all users.
# > ~/.bashrc is per user login...
# But AGAIN, you shouldn't need to do this, the ssh keys should just work by default
# at least in ubuntu