You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My expectation is that the given keyfile in the auths block would automatically handle finding the associated -cert file (openssh does this by default when provide ssh -i /suzieq/tls/gdc1/id_rsa [email protected]).
Working output from sq-poller:
[WORKER 0]: 2025-01-30 20:36:53,988 - asyncssh - INFO - Opening SSH connection to 172.28.184.3, port 22
[WORKER 0]: 2025-01-30 20:36:53,990 - asyncssh - INFO - [conn=0] Connected to SSH server at 172.28.184.3, port 22
[WORKER 0]: 2025-01-30 20:36:53,991 - asyncssh - INFO - [conn=0] Local address: 10.56.21.193, port 45272
[WORKER 0]: 2025-01-30 20:36:53,991 - asyncssh - INFO - [conn=0] Peer address: 172.28.184.3, port 22
[WORKER 0]: 2025-01-30 20:36:53,991 - asyncssh - DEBUG - [conn=0] Sending version SSH-2.0-AsyncSSH_2.14.2
[WORKER 0]: 2025-01-30 20:36:54,087 - asyncssh - DEBUG - [conn=0] Received version SSH-2.0-OpenSSH_8.0
[WORKER 0]: 2025-01-30 20:36:54,088 - asyncssh - DEBUG - [conn=0] Requesting key exchange
[WORKER 0]: 2025-01-30 20:36:54,103 - asyncssh - DEBUG - [conn=0] Received key exchange request
[WORKER 0]: 2025-01-30 20:36:54,104 - asyncssh - DEBUG - [conn=0] Beginning key exchange
[WORKER 0]: 2025-01-30 20:36:54,114 - asyncssh - DEBUG - [conn=0] Completed key exchange
[WORKER 0]: 2025-01-30 20:36:54,115 - asyncssh - INFO - [conn=0] Beginning auth for user root
[WORKER 0]: 2025-01-30 20:36:54,123 - asyncssh - DEBUG - [conn=0] Trying public key auth with [email protected] key
[WORKER 0]: 2025-01-30 20:36:54,131 - asyncssh - DEBUG - [conn=0] Trying public key auth with [email protected] key
[WORKER 0]: 2025-01-30 20:36:54,135 - asyncssh - DEBUG - [conn=0] Signing request with [email protected] key
[WORKER 0]: 2025-01-30 20:36:54,153 - asyncssh - INFO - [conn=0] Auth for user root succeeded
[WORKER 0]: 2025-01-30 20:36:54,153 - suzieq.poller.worker.nodes.node - INFO - Connected to 172.28.184.3:22 at 1738269414.1535795
[WORKER 0]: 2025-01-30 20:36:54,153 - suzieq.poller.worker.nodes.node - INFO - Connection succeeded via SSH for 172.28.184.3
[WORKER 0]: 2025-01-30 20:36:54,154 - asyncssh - DEBUG - [conn=0, chan=0] Set write buffer limits: low-water=16384, high-water=65536
[WORKER 0]: 2025-01-30 20:36:54,154 - asyncssh - INFO - [conn=0, chan=0] Requesting new SSH session
Observed Behavior
When running the poller, I see:
[WORKER 0]: 2025-01-29 22:10:46,792 - asyncssh - DEBUG - [conn=1] Sending version SSH-2.0-AsyncSSH_2.14.2
[WORKER 0]: 2025-01-29 22:10:46,947 - asyncssh - DEBUG - [conn=1] Received version SSH-2.0-OpenSSH_8.0
[WORKER 0]: 2025-01-29 22:10:46,948 - asyncssh - DEBUG - [conn=1] Requesting key exchange
[WORKER 0]: 2025-01-29 22:10:46,951 - asyncssh - DEBUG - [conn=1] Received key exchange request
[WORKER 0]: 2025-01-29 22:10:46,951 - asyncssh - DEBUG - [conn=1] Beginning key exchange
[WORKER 0]: 2025-01-29 22:10:46,961 - asyncssh - DEBUG - [conn=1] Completed key exchange
[WORKER 0]: 2025-01-29 22:10:46,962 - asyncssh - INFO - [conn=1] Beginning auth for user root
[WORKER 0]: 2025-01-29 22:10:46,969 - asyncssh - DEBUG - [conn=1] Trying public key auth with rsa-sha2-256 key
[WORKER 0]: 2025-01-29 22:10:47,704 - asyncssh - INFO - [conn=1] Auth failed for user root
[WORKER 0]: 2025-01-29 22:10:47,705 - asyncssh - INFO - [conn=1] Connection failure: Permission denied for user root on host 72.28.24.67
[WORKER 0]: 2025-01-29 22:10:47,705 - asyncssh - INFO - [conn=1] Aborting connection
[WORKER 0]: 2025-01-29 22:10:47,705 - suzieq.poller.worker.nodes.node - ERROR - Authentication failed to 172.28.184.3 Not retrying to avoid locking out user. Please restart poller with proper authentication.: Permission denied for user root on host 172.28.184.3
This message indicates it is using the id_rsa private key and not the id_rsa-cert.pub key: Trying public key auth with rsa-sha2-256 key.
What we should see is this:
Opening SSH connection to 172.28.24.67, port 22
[conn=0] Connected to SSH server at 172.28.24.67, port 22
[conn=0] Local address: 10.51.16.156, port 50330
[conn=0] Peer address: 172.28.24.67, port 22
[conn=0] Sending version SSH-2.0-AsyncSSH_2.14.2
[conn=0] Received version SSH-2.0-OpenSSH_8.0
[conn=0] Requesting key exchange
[conn=0] Received key exchange request
[conn=0] Beginning key exchange
[conn=0] Completed key exchange
[conn=0] Beginning auth for user root
[conn=0] Trying public key auth with [email protected] key
[conn=0] Trying public key auth with [email protected] key
[conn=0] Signing request with [email protected] key
[conn=0] Auth for user root succeeded
[conn=0, chan=0] Set write buffer limits: low-water=16384, high-water=65536
[conn=0, chan=0] Requesting new SSH session
[conn=0] Received unknown global request: [email protected]
[conn=0] Received debug message: cert: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
[conn=0] Received debug message: cert: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
[conn=0, chan=0] Command: echo "Hello, world!"
[conn=0, chan=0] Received exit status 0
[conn=0, chan=0] Received channel close
[conn=0, chan=0] Channel closed
[conn=0] Closing connection
[conn=0] Sending disconnect: Disconnected by application (11)
[conn=0] Connection closed
Which was produced by this test script (coming from the same container, etc.):
Note that passing in the keyfile value as id_rsa-cert.pub doesn't work as the _decrypt_pvtpkey() function expects a private key. If the cert is provided, the private key loading results in an error:
kex_algs='+diffie-hellman-group1-sha1', # for older boxes
encryption_algs='+aes256-cbc', # for older boxes
)
to
options=asyncssh.SSHClientConnectionOptions(
connect_timeout=self.connect_timeout,
username=self.username,
agent_identities=self.pvtkeyifself.pvtkeyelseNone,
# previous: client_keys=self.pvtkey if self.pvtkey else None,client_keys=["/suzieq/tls/gdc1/id_rsa"], # could also be: client_keys="/suzieq/tls/gdc1/id_rsa",password=self.passwordifnotself.pvtkeyelseNone,
kex_algs='+diffie-hellman-group1-sha1', # for older boxesencryption_algs='+aes256-cbc', # for older boxes
)
The connection is successful:
root>devices show
1 test-linux-node ah-aa-base02 server Linux 8.6 (Green Obsidian) Rocky alive 172.28.184.3 2025-01-16 15:01:24+00:00
root>
This seems to be as a result of asyncssh automatically handling the locating of keypath + "-cert" when passed a file path instead of a key object.
So it seems suzieq provides an asyncssh.SSHKey object in self.pvtkey . Since in my case, I am using cert-based auth, this actually breaks the auth flow. asyncssh handles this natively when provided a filepath to client_keys by automatically finding an associated pubkey in the filepath + "-cert" which is standard ssh functionality. So, when i hardcode the filepath as a string, it finds the cert correctly and authenticates.
Since suzieq handles _decrypt_pvtkey() before this, the self.pvtkey becomes an SSHKey type and certs no longer work. So, it seems some handling needs to be changed to support this better.
Suzieq version
0.23.0
Install Type
container
Python version
3.8
Impacted component
sq-poller
Steps to Reproduce
My environment has linux nodes that only use certificate-based authentication for ssh login. The sq-poller fails to login successfully.
Use a certificate keypair for certificate-based authentication to a linux node:
and a basic inventory:
Expected Behavior
My expectation is that the given
keyfile
in theauths
block would automatically handle finding the associated-cert
file (openssh does this by default when providessh -i /suzieq/tls/gdc1/id_rsa [email protected]
).Working output from sq-poller:
Observed Behavior
When running the poller, I see:
This message indicates it is using the id_rsa private key and not the id_rsa-cert.pub key:
Trying public key auth with rsa-sha2-256 key
.What we should see is this:
Which was produced by this test script (coming from the same container, etc.):
Note that passing in the keyfile value as
id_rsa-cert.pub
doesn't work as the_decrypt_pvtpkey()
function expects a private key. If the cert is provided, the private key loading results in an error:suzieq/suzieq/poller/worker/nodes/node.py
Lines 250 to 263 in ff56b88
Which is called from here:
suzieq/suzieq/poller/worker/nodes/node.py
Lines 156 to 158 in ff56b88
As a direct test, I adjusted
suzieq/suzieq/poller/worker/nodes/node.py
Lines 618 to 626 in ff56b88
The connection is successful:
This seems to be as a result of asyncssh automatically handling the locating of
keypath + "-cert"
when passed a file path instead of a key object.So it seems suzieq provides an asyncssh.SSHKey object in self.pvtkey . Since in my case, I am using cert-based auth, this actually breaks the auth flow. asyncssh handles this natively when provided a filepath to client_keys by automatically finding an associated pubkey in the filepath + "-cert" which is standard ssh functionality. So, when i hardcode the filepath as a string, it finds the cert correctly and authenticates.
Since suzieq handles _decrypt_pvtkey() before this, the self.pvtkey becomes an SSHKey type and certs no longer work. So, it seems some handling needs to be changed to support this better.
Screenshots
Additional Context
Relevant thread in slack: https://netenglabs.slack.com/archives/C015TD9DR8U/p1738176065631799
The text was updated successfully, but these errors were encountered: