kontena / pharos-cluster

Pharos - The Kubernetes Distribution
https://k8spharos.dev/
Apache License 2.0
311 stars 43 forks source link

Pharos does not honor system ssh config #443

Closed captncraig closed 6 years ago

captncraig commented 6 years ago

I have set ~/.ssh/config up with the following:

Host *kubecl*
    User svc_kubernetes
    IdentityFile ~/.ssh/kube.key

and my pharos config contains hosts like:

  - address: "devkubecl-node01.mydomain"
    private_address: "10.0.43.8"
    role: worker

Pharos does not seem to get the user/key from the ssh config:

ubuntu@devkubecl-node01.mydomain's password:

Fully specifying username and ssh key still works. Just specifying user or key alone are also not sufficient.

captncraig commented 6 years ago

The other context I hope to deploy from is teamcity. In that environment, the key will be pre-loaded into ssh-agent by the build runner, but the username will still come from the local ~/.ssh/config I think.

kke commented 6 years ago

I have a hunch that the username is always read from cluster.yml even if ssh config defines one. And if it doesn't, it will use the default, which is "ubuntu". Not optimal, will be fixed.

SpComb commented 6 years ago

The Pharos::Configuration::Host's user defaults to ubuntu... that's a bug at this point: https://github.com/kontena/pharos-cluster/blob/5c90b3ae3f6b8837f6de6b289df1dd85ff27e5a2/lib/pharos/configuration/host.rb#L17

captncraig commented 6 years ago

Making progress... after testing with 1.2.0 rc1, it gets the right username, but still doesn't use the IdentityFile from the config. Prompts for password still.

kke commented 6 years ago

The fix didn't remove the default value for ssh_key_path.

attribute :ssh_key_path, Pharos::Types::Strict::String.default('~/.ssh/id_rsa')