bubblebath
bubblebath

Reputation: 999

Github ssh key push only

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

Answers (1)

mipadi
mipadi

Reputation: 410662

You can do two things:

  1. You can set up the remote to use SSH for both pulling/pushing.
  2. You can use the configuration option 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

Related Questions