Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch git protocol from https to ssh only when authentication needed

Tags:

git

ssh

I'm using YubiKey (PIV smart card with USB) to store my ssh credential for GitHub. Every time I access to GitHub via ssh, I need to insert the key and put pin. It's a bit stressful and I want to avoid it if it is not needed. For example, on cloning the public repo, I don't need to authenticate when I do that via https.

I can enforce git client to use ssh everywhere:

[url "[email protected]:"]
    insteadOf = https://github.com/

But I do not want to enforce ssh everywhere. I want it only when authentication is needed.

Does anyone know good ways?

like image 806
aiotter Avatar asked Sep 22 '26 17:09

aiotter


1 Answers

You can change remote url to http protocol using: git remote set-url origin http://new.git.url/here.

Documentation.

like image 68
ceth Avatar answered Sep 25 '26 08:09

ceth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!