-
-
Save asksven/b37e8d83eca7f77484be9dd7af2b98e6 to your computer and use it in GitHub Desktop.
If 2fa is enabled on github switch to ssh instead of https on linux | |
1. generate an ssh keypair on your linux box | |
ssh-keygen -t {rsa|dsa} | |
2. add the public key to github: profile - settings - ssh keys | |
3. switch from https to ssh | |
Check your repo remote: | |
git remote -v | |
should show: | |
origin https://github.com/USERNAME/REPOSITORY.git (fetch) | |
origin https://github.com/USERNAME/REPOSITORY.git (push) | |
Change the remote: | |
git remote set-url origin [email protected]:USERNAME/OTHERREPOSITORY.git | |
verify: | |
git remote -v | |
should show: | |
origin [email protected]:USERNAME/OTHERREPOSITORY.git (fetch) | |
origin [email protected]:USERNAME/OTHERREPOSITORY.git (push) |
Hi, thanks for this. How can I configure Github to always use the ssh URL rather than https for all repositories I create?
Gitlab decides on the protocol based on the protocol in the URI or the repo. This can be changed after the fact by changing the remote URI using "git remote" (-v to list them)
Worked like a charm
Thank you!
When changing origin is not an option we can use this config:
git config --global url."ssh://[email protected]".insteadOf "https://github.com"
Very useful, thanks!
Thanks!
Thank you!
Thank you, it works
Thanks! Works like a charm and it helps me resolve the error "fatal: could not read Username for 'https://github.com': Device not configured"
Is there a more elegant way?
@xiaohaoo It's not that complicated, just switch the URL with a simple command or git clone the SSH URI if it's a new setup. No need to complicate it, what more elegance would you expect?
Amazing! Thanks!
When changing origin is not an option we can use this config:
git config --global url."ssh://[email protected]".insteadOf "https://github.com"
This got helpful for me. Thank you. ❤️
Useful ! thanks !
Thanks a lot man, just what I was looking for