From 17e6319f75660e6a034aacf98ad41f4e0ef54690 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 14 Nov 2026 10:08:27 -0500 Subject: [PATCH] Leverage the askpass facility from sshutil in nodeshell This allows a user to pass a password by environment variable. --- confluent_client/bin/nodeshell | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/confluent_client/bin/nodeshell b/confluent_client/bin/nodeshell index 23a15703..fb0d900e 100755 --- a/confluent_client/bin/nodeshell +++ b/confluent_client/bin/nodeshell @@ -57,6 +57,8 @@ def run(): help='Timeout in seconds for each node ssh connection') argparser.add_option('-x', '--noexpression', action='store_true', help='Suppress expression expansion of command') + argparser.add_option('-e', '--environmentpassword', type='str', + help='Environment variable containing the password to use for ssh') argparser.add_option('-m', '--maxnodes', type='int', help='Specify a maximum number of ' 'nodes to run remote ssh command to, ' @@ -112,6 +114,14 @@ def run(): for node in ex: cmdparms.append((node, ex[node]['value'])) poller = select.epoll() + if options.environmentpassword: + sshpass = os.environ.get(options.environmentpassword) + if sshpass: + askpass = '/opt/confluent/libexec/confluent_askpass.sh' + os.environ['SSH_ASKPASS_REQUIRE'] = 'force' + os.environ['CONFLUENT_SSH_PASSPHRASE'] = sshpass + os.environ['DISPLAY'] = 'NONE' + os.environ['SSH_ASKPASS'] = askpass for node, cmd in cmdparms: sshnode = nodemap.get(node, node) if not isinstance(cmd, str) and not isinstance(cmd, bytes):