Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEST: Current value of ssh_hash_known_hosts causes error in the default configuration in FIPS mode #5925

Closed
wants to merge 5 commits into from

Conversation

dparmar18
Copy link

Explanation

  • In SSSD the default value for ssh_hash_known_hosts is set to true,
    It should be changed to false for consistency with the OpenSSH
    setting that does not hashes hostnames by default

Verifies
Issue: #5848
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2014249

Copy link
Contributor

@sgoveas sgoveas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

ssh_hash_known_hosts
"""
tools = sssdTools(multihost.client[0])
server_host = multihost.master[0].sys_hostname
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this host added at IPA server?

@dparmar18 dparmar18 force-pushed the test_ssh_hash_knownhosts branch 2 times, most recently from ce2e1b2 to b0a2085 Compare January 7, 2022 15:39
if "ssh_hash_known_hosts" in sssd_conf:
ssh_section = "ssh"
ssh_param = {"ssh_hash_known_hosts": ""}
tools.sssd_conf(ssh_section, ssh_param, action="delete")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you use action="delete" unconditionally (without check option is present first)? What happens if you try to delete non-existent option?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I try to delete that doesn't exist then it will throw exception

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't it support "nothrow" mode/arg?
But even if it throws, it would be easier to try/catch than to check.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test case will be skipped upon encountering an exception therefore as discussed I'll have to stick with this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does is it work in case exception is handled in place?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually, it would skip from there but I found a workaround for expecting an exception and still continue the execution, I'll push it if it succeeds.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What "it"?
If you handle exception in place it doesn't propagate anywhere.

…lt configuration in FIPS mode.

Explanation
- In SSSD the default value for ssh_hash_known_hosts is set to true,
  It should be changed to false for consistency with the OpenSSH
  setting that does not hashes host names by default

Verifies
  Issue: SSSD#5848
  Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2014249
multihost.master[0].run_command("ipa host-mod %s --sshpubkey="
"\"$(cat /tmp/ssh_host0003_rsa.pub)\" "
"--updatedns"
% multihost.client[0].sys_hostname)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this.

  1. You assign a key to client[0].sys_hostname but later test looks for master[0].sys_hostname. This doesn't make sense.
    Probably this works because IPA master has own key always set? I don't know this. Could you please check?

  2. ssh-keyscan should be used to figure out key of a host, not a new random key generated and assigned in IPA db.
    (but answer to 1) is more important)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I'm not assigning a key to client[0].sys_hostname, here I'm running this command on the server that adds a key bound with the client host. It will be like ipa host-mod client.ipa.test --sshpubkey="$(cat /tmp/ssh_host0003_rsa.pub)" --updatedns where client.ipa.test is a client i.e client[0].sys_hostname

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can call it "bound" instead of "assign" but that doesn't change a thing.

Later test looks for server_host (if server_host in known_hosts.stdout_text ...), not for a "client.ipa.test".

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes because SSH is being done on client:
multihost.client[0].run_command(cmd,stdin_text="Secret123",raiseonerr=False)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes because SSH is being done on client: multihost.client[0].run_command(cmd,stdin_text="Secret123",raiseonerr=False)

It doesn't matter where ssh is being executed - every node will receive the same map from the server.
This is just a mean to trigger known-hosts list update.

Your test makes sure client's key (fingerprint) is specified in the list, but searches for server's key.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on this now, thanks for acknowledging.

@alexey-tikhonov
Copy link
Member

And it still fails pycodestyle:

./src/tests/multihost/ipa/test_misc.py:388:58: W292 no newline at end of file

@dparmar18
Copy link
Author

And it still fails pycodestyle:

./src/tests/multihost/ipa/test_misc.py:388:58: W292 no newline at end of file

I hope it passes now, have pushed the required changes

@alexey-tikhonov
Copy link
Member

Please rebase to the latest master branch.

@dparmar18 dparmar18 force-pushed the test_ssh_hash_knownhosts branch 3 times, most recently from eca0bd6 to 2124ffd Compare February 14, 2022 13:27
@dparmar18
Copy link
Author

This PR had conflicts while rebasing, therefore here is the new PR with everything sorted: #5996

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changes requested superseded This PR is superseded in favor if a different one Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants