Skip to content

Instantly share code, notes, and snippets.

@lotusirous
Last active December 17, 2017 05:03
Show Gist options
  • Save lotusirous/8b35f509be1df100efa334251ef70e33 to your computer and use it in GitHub Desktop.
Save lotusirous/8b35f509be1df100efa334251ef70e33 to your computer and use it in GitHub Desktop.
Git authen by SSH key

Generate SSH public and private SSH key:

Follow this tutorial: https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

Add key to agent

https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/

Change remote origin to ssh style

Your git config is similar to this:

git config -l
[email protected]
user.name=lotusirous
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://github.com/lotusirous/your_repository.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

Then, you change repo protocol variable remote.origin.url from https to ssh. Thanks to this answer: https://stackoverflow.com/questions/1595848/configuring-git-over-ssh-to-login-once

git config remote.origin.url [email protected]:your_username/your_project.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment