Hub: Feature request: specify SSH alias instead of "[email protected]"

Created on 29 Mar 2012  路  2Comments  路  Source: github/hub

I use SSH aliases extensively for managing multiple different SSH keys. I have an alias set up for github that automatically supplies my private key, so that I can do git clone github:singingwolfboy/myrepo.git and have it work for both push and pull. It would be awesome if I could specify my SSH alias to hub so that it does this for me: with my current setup, I can do hub clone singingwolfboy/myrepo, but then I'm unable to push because it doesn't pick up my SSH private key.

It would be even more awesome if I could specify this on the github website, so that the autogenerated copy-paste commands on project pages would contain my SSH alias rather than simply [email protected], but that's a _much_ larger scope than this feature request.

Most helpful comment

SSH aliases are neat. I use them a lot.

However I feel like you're missing the point of aliases. Their only purpose is to save you typing in the command-line and, sometimes, to give nicer name to hosts that are not that nice.

Aliases are not there to be able to assign them an SSH key. You can assign keys to real hostnames and even to hostname patterns:

# your old config
Host github
  HostName github.com
  User git
  IdentityFile ~/.ssh/blah

# add this extra config
Host github.com *.example.org
  User git
  IdentityFile ~/.ssh/blah

When you do hub clone singingwolfboy/myrepo, it will use "github.com" as the host. And that's fine, because you didn't have to type it. If it used just "github", which is your alias, it wouldn't make any difference because you never needed to type the hostname.

For the same reason, I doubt that GitHub will ever change their copy-paste commands. You don't need to care how long they are. You just need to copy-paste them.

All 2 comments

SSH aliases are neat. I use them a lot.

However I feel like you're missing the point of aliases. Their only purpose is to save you typing in the command-line and, sometimes, to give nicer name to hosts that are not that nice.

Aliases are not there to be able to assign them an SSH key. You can assign keys to real hostnames and even to hostname patterns:

# your old config
Host github
  HostName github.com
  User git
  IdentityFile ~/.ssh/blah

# add this extra config
Host github.com *.example.org
  User git
  IdentityFile ~/.ssh/blah

When you do hub clone singingwolfboy/myrepo, it will use "github.com" as the host. And that's fine, because you didn't have to type it. If it used just "github", which is your alias, it wouldn't make any difference because you never needed to type the hostname.

For the same reason, I doubt that GitHub will ever change their copy-paste commands. You don't need to care how long they are. You just need to copy-paste them.

I just tried adding the "github.com" to the Host line of my config, and now everything just works. Thanks! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stsewd picture stsewd  路  4Comments

iserko picture iserko  路  4Comments

DennisSchiefer picture DennisSchiefer  路  4Comments

dsifford picture dsifford  路  4Comments

kurko picture kurko  路  4Comments