Reputation: 999
I have a github repo and I was wondering if it is possible to remove the ability to push to a repo without a ssh key.
I have had a look and can't see anything about having only an ssh-key that will let me push rather than both ssh push and a push where I enter my username and password.
Thanks
Upvotes: 0
Views: 413
Reputation: 410662
You can do two things:
url.<base>.pushInsteadOf
. So, for example, if the repo remote's URL is https://github.com/me/blah.git
, run git config url.'[email protected]:'.pushInsteadOf 'https://github.com/'
. Now, when you try to push into https://github.com/me/blah.git
, Git will use the SSH url instead of the HTTPS one.You can't prevent pushing over HTTPS for all users in a GitHub repo, but if you host the repo on your own server you can elect not to serve it over HTTPS at all.
Upvotes: 1