48.5. Managing public SSH keys for hosts
OpenSSH uses public keys to authenticate hosts. One machine attempts to access another machine and presents its key pair. The first time the host authenticates, the administrator on the target machine has to approve the request manually. The machine then stores the host’s public key in a known_hosts file. Any time that the remote machine attempts to access the target machine again, the target machine checks its known_hosts file and then grants access automatically to approved hosts.
48.5.1. Uploading SSH keys for a host using the IdM Web UI 링크 복사링크가 클립보드에 복사되었습니다!
Identity Management allows you to upload a public SSH key to a host entry. OpenSSH uses public keys to authenticate hosts.
Prerequisites
- Administrator privileges for managing the IdM Web UI or User Administrator role.
Procedure
You can retrieve the key for your host from a
~/.ssh/known_hostsfile. For example:server.example.com,1.2.3.4 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEApvjBvSFSkTU0WQW4eOweeo0DZZ08F9Ud21xlLy6FOhzwpXFGIyxvXZ52+siHBHbbqGL5+14N7UvElruyslIHx9LYUR/pPKSMXCGyboLy5aTNl5OQ5EHwrhVnFDIKXkvp45945R7SKYCUtRumm0Iw6wq0XD4o+ILeVbV3wmcB1bXs36ZvC/M6riefn9PcJmh6vNCvIsbMY6S+FhkWUTTiOXJjUDYRLlwM273FfWhzHK+SSQXeBp/zIn1gFvJhSZMRi9HZpDoqxLbBB9QIdIw6U4MIjNmKsSI/ASpkFm2GuQ7ZK9KuMItY2AoCuIRmRAdF8iYNHBTXNfFurGogXwRDjQ==You can also generate a host key. See Generating SSH keys.
Copy the public key from the key file. The full key entry has the form
host name,IP type key==. Only thekey==is required, but you can store the entire entry. To use all elements in the entry, rearrange the entry so it has the ordertype key== [host name,IP].# cat /home/user/.ssh/host_keys.pub ssh-rsa AAAAB3NzaC1yc2E...tJG1PK2Mq++wQ== server.example.com,1.2.3.4- Log into the IdM Web UI.
- Go to the Identity>Hosts tab.
- Click the name of the host to edit.
- In the Host Settings section, click the SSH public keys Add button.
- Paste the public key for the host into the SSH public key field.
- Click Set.
- Click Save at the top of the IdM Web UI window.
Verification
- Under the Hosts Settings section, verify the key is listed under SSH public keys.
48.5.2. Uploading SSH keys for a host using the IdM CLI 링크 복사링크가 클립보드에 복사되었습니다!
Identity Management allows you to upload a public SSH key to a host entry. OpenSSH uses public keys to authenticate hosts. Host SSH keys are added to host entries in IdM, when the host is created using host-add or by modifying the entry later.
Note RSA and DSA host keys are created by the ipa-client-install command, unless the SSH service is explicitly disabled in the installation script.
Prerequisites
- Administrator privileges for managing IdM or User Administrator role.
Procedure
Run the
host-modcommand with the--sshpubkeyoption to upload the base64-encoded public key to the host entry.Because adding a host key changes the DNS Secure Shell fingerprint (SSHFP) record for the host, use the
--updatednsoption to update the host’s DNS entry. For example:$ ipa host-mod --sshpubkey="ssh-rsa RjlzYQo==" --updatedns host1.example.comA real key also usually ends with an equal sign (=) but is longer.
To upload more than one key, enter multiple --sshpubkey command-line parameters:
--sshpubkey="RjlzYQo==" --sshpubkey="ZEt0TAo=="Note that a host can have multiple public keys.
- After uploading the host keys, configure SSSD to use Identity Management as one of its identity domains and set up OpenSSH to use the SSSD tools for managing host keys, covered in Configuring SSSD to Provide a Cache for the OpenSSH Services.
Verification
Run the
ipa host-showcommand to verify that the SSH public key is associated with the specified host:$ ipa host-show client.ipa.test ... SSH public key fingerprint: SHA256:qGaqTZM60YPFTngFX0PtNPCKbIuudwf1D2LqmDeOcuA client@IPA.TEST (ssh-rsa) ...
48.5.3. Deleting SSH keys for a host using the IdM Web UI 링크 복사링크가 클립보드에 복사되었습니다!
You can remove the host keys once they expire or are no longer valid. Follow the steps below to remove an individual host key by using the IdM Web UI.
Prerequisites
- Administrator privileges for managing the IdM Web UI or Host Administrator role.
Procedure
- Log into the IdM Web UI.
- Go to the Identity>Hosts tab.
- Click the name of the host to edit.
- Under the Host Settings section, click Delete next to the SSH public key you want to remove.
- Click Save at the top of the page.
Verification
- Under the Host Settings section, verify the key is no longer listed under SSH public keys.
48.5.4. Deleting SSH keys for a host using the IdM CLI 링크 복사링크가 클립보드에 복사되었습니다!
You can remove the host keys once they expire or are no longer valid. Follow the steps below to remove an individual host key by using the IdM CLI.
Prerequisites
- Administrator privileges for managing the IdM CLI or Host Administrator role.
Procedure
To delete all SSH keys assigned to a host account, add the
--sshpubkeyoption to theipa host-modcommand without specifying any key:$ kinit admin $ ipa host-mod --sshpubkey= --updatedns host1.example.comNote that it is good practice to use the
--updatednsoption to update the host’s DNS entry.IdM determines the key type automatically from the key, if the type is not included in the uploaded key.
Verification
Run the
ipa host-showcommand to verify that the SSH public key is no longer associated with the specified host:$ ipa host-show client.ipa.test Host name: client.ipa.test Platform: x86_64 Operating system: 4.18.0-240.el8.x86_64 Principal name: host/client.ipa.test@IPA.TEST Principal alias: host/client.ipa.test@IPA.TEST Password: False Member of host-groups: ipaservers Roles: helpdesk Member of netgroups: test Member of Sudo rule: test2 Member of HBAC rule: test Keytab: True Managed by: client.ipa.test, server.ipa.test Users allowed to retrieve keytab: user1, user2, user3