Best way to import ssh keys?

Hello,

what is the best way to import SSH-Keys to a provisioned Machine by foreman?
Before my Foreman Installation I added all my Keys into the Kickstart file, but now I think there is a better way.
In my “Kickstart default finish” prov Template i saw the variable/Snippet “remote_execution_ssh_keys”. Where i can change this one? How to create a new Variable like this?

Regards :slight_smile:

Hi,

the snippets are not variables but templates themselves, which are usually used in other templates.
For example the remote_execution_ssh_keys-snippet is not only used in the kickstart default finish, but also in kickstart default, preseed finish and autoyast.
In this case the ssh-keys for remote execution are read from all smart proxies and added to the authorized_keys during provisioning. You could also create a special ssh-user with sudo-priviledges using this snippet.

If you have already provisioned machines and you also use Katello, you could use the bootstrap.py-script to register them and there is also an option to add the ssh-keys for remote execution.

Another way would be a configuration management tool such as puppet to manage ssh-keys on the machine.

If you plan to adapt templates, i recommend to clone an existing one and edit it then. If you unlock and edit community templates your changes might be overwritten during upgrades.


ATIX AG - https://atix.de

This might be a useful reference: Managing Hosts

If you search for SSH keys, there is other info as part of other procedures.

You’re right, but the snippet also checks for existence of the parameter and if it finds it and is a string, it deploys that string as a key. If it returns array (rex plugin is present), the array contains keys from all proxies.

In other words, without rex plugin, it should be enough to set the key in the remote_execution_ssh_keys parameter. E.g. define that as a global parameter.

The remote_execution_ssh_keys is a parameter that can be set on multiple levels:

  • Global level (Configure > Global Parameters)
  • Organization / Location (Administer > Organizations / locations
  • Host Group (Configure > Host groups)
  • Operating System (Hosts > Operating systems)
  • Host

For example you can set some ssh keys that you want for all systems, than you will set it at global level.

But if you have some keys let’s say only for Ubuntu systems, you can set the parameter on Ubuntu OS and Foreman during provisioning of Ubuntu system takes the value from Operating System level.

1 Like