Configuring ssh keys for GibHub

I follow these instructions on how to configure SSH keys for use with GibHub.

The instructions say that you delete your current directory .sshand create new keys in this .ssh directory. I cannot do this because I already have keys in mine id_dsa.pubthat I need to use for other servers.

Is it possible to configure ssh for GitHub while keeping the keys that I already saved in .ssh? Or is there any other way to configure ssh for GitHub?

+5
source share
3 answers

You can either reuse your key pair already in your directory, or create a new key pair specifically for using github. If you decide not to use the default pair, you will need to modify your file ~/.ssh/configand add the host definition for Github, pointing it to the new key file. So, if your new key pair github_rsaand github_rsa.pub, put these lines in /.ssh/config:

Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/github_rsa

Now, when you perform push or push operations before git@github.com, an alternate authentication file will be used.

+7
source

You can create keys with specific names, for example

ssh-keygen -t rsa -f ~/.ssh/id_rsa_github -C "your_email@youremail.com"

and then you can specify this key for a separate server in the ~ / .ssh / config file

Host *github.com
  IdentityFile ~/.ssh/id_rsa_github
  User git

See man sshor for details man ssh_config.

+5
source

, :

git config --global credential.helper osxkeychain
0

All Articles