SUSE / machinery

A systems management toolkit for Linux
GNU General Public License v3.0
158 stars 32 forks source link

Support ssh config files (defined by a parameter) #2233

Open ludwig-gramberg opened 7 years ago

ludwig-gramberg commented 7 years ago

When having multiple projects with multiple sets of ssh-keys and ssh_config files (one for each project) it is very important to be able to define a ssh_config file by parameter.

The (outstanding) example here being ansible: I can define a ssh_config file in my ansible.cfg and now the key, the known_hosts etc. is all defined.

Why this is important: I'm accessing many servers/containers through a vpn or bastion hosts. So for my local machine I need to separate ssh-contexts by project otherwise ip-ranges (10.11.0.x) would overlap.

Example of ssh_config:

UserKnownHostsFile = ./.ssh/known_hosts
ServerAliveInterval 15
ConnectTimeout 30
UseRoaming no
IdentitiesOnly yes

Host *
  ControlMaster auto
  ControlPath ./.ssh/cm_socket_%r@%h:%p
  ControlPersist 30m

Host 33.33.33.33 myhost.domain.suffix
  HostName 33.33.33.33
  IdentityFile ./.ssh/keys/%r_ed25519

Host 10.11.0.10 container-a
  HostName 10.11.0.10
  IdentityFile ./.ssh/keys/%r_ed25519
  ProxyCommand ssh -F ./ssh.cfg -W %h:%p %r@33.33.33.33

Host 10.11.0.11 container-b
  HostName 10.11.0.11
  IdentityFile ./.ssh/keys/%r_ed25519
  ProxyCommand ssh -F ./ssh.cfg -W %h:%p %r@33.33.33.33

# (ips are just examples)

a command is then run locally as such:

ssh -F ssh.cfg someuser@container-a or ssh -F ss.cfg someuser@myhost.domain.suffix