xorpaul / g10k

my r10k fork in Go
Apache License 2.0
125 stars 50 forks source link

Use ssh-agent to get key password #171

Closed DavidGamba closed 3 years ago

DavidGamba commented 3 years ago

I am trying to use the option to clone repositories with an SSH key that has a password.

The key is already in my ssh-agent. Can the clone be done using that key?

nudgegoonies commented 3 years ago

Same problem here. Having two SSH Keys, both are loaded, and git commands for repositories via ssh work flawless.

But g10k first brings a graphical dialog for my first key and then asks in the console for the second key and then in loop for further repos until i gave up.

Maybe this ticket is related because we also have this kind of internal modules too "mod '$NAME', :git => 'ssh://git@$SERVERNAME': https://github.com/xorpaul/g10k/issues/62 But in contrast to this ticket we use git via ssh and ssh and git via ssh works otherwise with the exception of g10k.

xorpaul commented 3 years ago

Yeah, this happens because g10k tries to add/load the SSH key before each git command targeting a non http repository URL, see https://github.com/xorpaul/g10k/blob/fe43a33fab97a9b8ac17f6e4250ce0429cb20b31/git.go#L119

I could add a parameter to the g10k config where the SSH key is specified, so that g10k should not do the above and simply trusts that the user already added the SSH key to an SSH agent.

Sounds good?

nudgegoonies commented 3 years ago

Yes, sounds very good!

nudgegoonies commented 3 years ago

Any news on this?

xorpaul commented 3 years ago

Nope, but it's not forgotten. Give me a little bit more time and I'll come back with a solution.

nudgegoonies commented 3 years ago

Thank you!

xorpaul commented 3 years ago

Checkout https://github.com/xorpaul/g10k/releases/tag/v0.8.13

Usage:

mod 'example_module',
  :git => 'git@somehost.com/foo/example-module.git',
  :branch => 'foo',
  :use_ssh_agent => true