How do I use GitHub with SSH without having to run ssh-agent?
Asked Answered
D

1

18

In order to push/pull from GitHub using SSH, I have to...

$ eval $(ssh-agent -s)
$ ssh-add ~/.ssh/git_id_rsa
$ git push origin master

However, when I push/pull to remote git repositories I host on my own private server, I can skip the whole ssh-agent stuff and simply

$ git push origin master

How do I do the same with GitHub (push/pull without ssh-agent set-up and ssh-add)?

  • My id_rsa keys do not have passphrases associated with them
  • I am comfortable with the level of security this provides
  • I know how to set-up bash aliases for these, and run them on start-up/bash exit, but I would rather not deal with them at all
Dogie answered 22/6, 2017 at 13:32 Comment(0)
A
22

You can use config file in .ssh directory of your user in order to configure key for particular server:

# ~/.ssh/config
Host github.com
    IdentityFile ~/.ssh/git_id_rsa

You can find more detail on Simplify Your Life With an SSH Config File.

Asmodeus answered 22/6, 2017 at 13:39 Comment(1)
Worked! I was already using a ssh_config file, but my Host was github.com:username, and I had configs under that. I think one of those may have been the issue here.Dogie

© 2022 - 2024 — McMap. All rights reserved.