Last active
November 23, 2022 20:59
-
-
Save 2lach/da89e5593fcd00f86f4f27c2e2463677 to your computer and use it in GitHub Desktop.
how to setup git with ssh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh-keygen -t rsa -b 4096 -C "gituser@email.com" | |
eval "$(ssh-agent -s)" | |
# if there is no 'config' file in ~/.ssh | |
touch ~/.ssh/config | |
---------------------------------- | |
# in file config, this will add ssh to keychain | |
---------------------------------- | |
Host * | |
AddKeysToAgent yes | |
UseKeychain yes | |
IdentityFile ~/.ssh/id_rsa | |
---------------------------------- | |
# else skip to | |
ssh-add -K ~/.ssh/id_rsa | |
# create private key | |
ssh-add -K ~/.ssh/id_rsa | |
# copy public key and paste in github | |
pbcopy < ~/.ssh/id_rsa.pub | |
# after git rsa use git clone or something | |
# you can verify cause github will be on known_hosts | |
cat ~/.ssh/known_hosts | |
# ---- GITLAB -------- # | |
ssh-keygen -t rsa -b 4096 -C "user@email.com" | |
pbcopy < ~/.ssh/id_rsa_gitlab.pub | |
# paste it in git ssh section | |
# test it | |
ssh -T git@gitlab.com | |
# if error run (v = verbose): | |
# ssh -Tv git@gitlab.com | |
# now it should be in | |
cat ~/.ssh/known_hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment