Skip to content

Add XML client options as alternatives to --ssh-key-file and --ssh-key-passphrase - #87786

Open
larry-cdn77 wants to merge 3 commits into
ClickHouse:masterfrom
larry-cdn77:client-ssh-key-file-and-passphrase-xml-options
Open

larry-cdn77 wants to merge 3 commits into
ClickHouse:masterfrom
larry-cdn77:client-ssh-key-file-and-passphrase-xml-options

Conversation

@larry-cdn77

@larry-cdn77 larry-cdn77 commented Sep 28, 2025 •

Copy link
Copy Markdown
Contributor

Convenience

Changelog category

  • New Feature

Changelog entry

Client options --ssh-key-file and --ssh-key-passphrase can now be specified in XML configuration as <ssh_key_file/> and <ssh_key_passphrase/> (same as user or password)

Documentation entry for user-facing changes

The client does not currently have its own website documentation but new options added to --help usage as well as example clickhouse-client.xml

@rienath rienath added the can be tested Allows running workflows for external contributors label Sep 29, 2025
@clickhouse-gh

clickhouse-gh Bot commented Sep 29, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [918b124]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_asan, flaky) failure
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_ed25519[3-3] FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_argument_password_environment_password[2-3] FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_key_argument_password[3-3] FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_key_argument_key[1-3] FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_rsa[2-3] FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_wrong_key[3-3] FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_key[3-3] FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_password_argument_password[1-3] FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_key_argument_password_environment_password[3-3] FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_key[1-3] FAIL cidb
50 more test cases not shown
Integration tests (amd_asan, db disk, old analyzer, 6/6) failure
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_ecdsa FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_ed25519 FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_rsa FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_wrong_key FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_key_with_passphrase FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_key FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_password_argument_password FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_password_argument_key FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_password_environment_password FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_argument_password_environment_password FAIL cidb
10 more test cases not shown
Integration tests (amd_binary, 2/5) failure
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_ecdsa FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_ed25519 FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_rsa FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_wrong_key FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_key_with_passphrase FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_key FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_password_argument_password FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_password_argument_key FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_password_environment_password FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_argument_password_environment_password FAIL cidb
10 more test cases not shown
Integration tests (arm_binary, distributed plan, 2/4) failure
test_userspace_page_cache/test.py::test_size_adjustment FAIL cidb, issue
Integration tests (arm_binary, distributed plan, 4/4) failure
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_ecdsa FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_ed25519 FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_rsa FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_wrong_key FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_key_with_passphrase FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_key FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_password_argument_password FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_password_argument_key FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_password_environment_password FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_argument_password_environment_password FAIL cidb
10 more test cases not shown
Integration tests (amd_tsan, 2/6) failure
test_scheduler_cpu_preemptive/test.py::test_downscaling[cpu-slot-preemption-timeout-1ms] FAIL cidb, issue
Integration tests (amd_tsan, 6/6) failure
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_ecdsa FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_ed25519 FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_rsa FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_wrong_key FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_key_with_passphrase FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_key FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_password_argument_password FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_password_argument_key FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_configuration_password_environment_password FAIL cidb
test_ssh_keys_authentication/test_ssh_keys_authentication.py::test_argument_password_environment_password FAIL cidb
10 more test cases not shown
Finish Workflow failure
python3 ./ci/jobs/scripts/workflow_hooks/feature_docs.py failure

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Sep 29, 2025
@nikitamikhaylov nikitamikhaylov self-assigned this Sep 29, 2025
@larry-cdn77

larry-cdn77 commented Sep 30, 2025 •

Copy link
Copy Markdown
Contributor Author

Command line override can no longer change authentication from SSH key to password:

% clickhouse client -u foo --password bar
DB::Exception: Expected authentication with SSH key. (AUTHENTICATION_FAILED)

I see the issue is that SSH key has priority over password, regardless of where you specify it

Would it be to weird to clear ssh-key-file/passphrase if --password or CLICKHOUSE_PASSWORD are encountered?

@larry-cdn77
larry-cdn77 force-pushed the client-ssh-key-file-and-passphrase-xml-options branch from 5bbdb92 to 2f414eb Compare September 30, 2025 12:47
…natives to --ssh-key-file and --ssh-key-passphrase
@larry-cdn77

larry-cdn77 commented Sep 30, 2025 •

Copy link
Copy Markdown
Contributor Author

Would it be to weird to clear ssh-key-file/passphrase if --password or CLICKHOUSE_PASSWORD are encountered?

I have realised that CLI arguments and environment variables are loaded first, before config.xml, somewhat against my initial intuition 🙂

So what I have done is make <ssh_key_file> only apply if no --password or CLICKHOUSE_PASSWORD set

@nikitamikhaylov

Copy link
Copy Markdown
Member

Please write a test. You add add it to the tests/integration/test_ssh_keys_authentication

@larry-cdn77

larry-cdn77 commented Sep 30, 2025 •

Copy link
Copy Markdown
Contributor Author

I have begun working on it

I noticed that in the current implementation CLICKHOUSE_PASSWORD does not override <password/> – is that intentional?

@clickhouse-gh

clickhouse-gh Bot commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

Dear @nikitamikhaylov, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@larry-cdn77

larry-cdn77 commented Dec 29, 2025 •

Copy link
Copy Markdown
Contributor Author

I noticed that in the current implementation CLICKHOUSE_PASSWORD does not override – is that intentional?

I will stick to the priorities used by other options such as history file, and these are:

  1. defaults
  2. environment
  3. configuration file
  4. command line arguments

@larry-cdn77

larry-cdn77 commented Dec 29, 2025 •

Copy link
Copy Markdown
Contributor Author

Would it help clarity to disallow specifying both a password and an SSH key? Currently --ssh-key-file overrides --password which can come across confusing.

This PR introduces additional such scenarios, eg <ssh_key_file> and <password> specified at the same time.

@larry-cdn77

larry-cdn77 commented Dec 31, 2025 •

Copy link
Copy Markdown
Contributor Author

#90985 seems to have broken SSH key authentication on my production clusters – raised as #93302.

…natives to --ssh-key-file and --ssh-key-passphrase (integration test)
@larry-cdn77

larry-cdn77 commented Jan 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Ready for review – now with additional tests, a check for simultaneous password + SSH key, all using the said priorities (CLI argument over configuration file over enviroment) cc @nikitamikhaylov

@larry-cdn77

Copy link
Copy Markdown
Contributor Author

A gentle reminder, thanks!

@abashkeev abashkeev added the comp-cli clickhouse-client (interactive CLI) and client library. label Sep 3, 2026
@maxknv maxknv added the external Author is not a member of the ClickHouse organization label Nov 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-cli clickhouse-client (interactive CLI) and client library. external Author is not a member of the ClickHouse organization pr-feature Pull request with new product feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants