UnprocessableEntityError: SSH Connection Error: Encountered RSA Key, Expected OPENSSH Key
Symptom
When you register a Linux system through the API, the registration returns the following error:
{
"name": "UnprocessableEntityError",
"message": "SSH connection error: encountered RSA key, expected OPENSSH key",
"code": 9999
}
Cause
One of the following causes applies:
- SSH access is limited to specific accounts. For example, the
/etc/ssh/sshd_configfile specifies theAllowUsersorAllowGroupsoption. - The system was already registered in Netwrix Privilege Secure for Discovery, and a user was removed from the system. This applies even if the user was added back manually.
- The system runs Ubuntu 22.04 or later, which does not allow RSA SSH keys by default.
Resolution
Allow SSH Access for the Service Account
Either change the configuration to allow SSH access for all users, or add the service account to the relevant AllowUsers or AllowGroups lines. The default service account name is secureone. Then restart the sshd service.
Remove the User and the Database Record
IMPORTANT: This procedure deletes data from the product database. Back up the database before you continue, and confirm the system name before you run the delete command.
-
Remove the user and the home directory from the system:
sudo deluser --remove-home secureone -
If the user was removed but the home directory remains, remove the home directory manually:
sudo rm -r /home/secureone -
Connect to a node over SSH, and open the database shell:
- For a cluster deployment, run
s1 db. - For a single-node deployment, run
s1 --single-node db.
- For a cluster deployment, run
-
Find the system records. In this example,
linux01is the system name:db.ldap_store.find({ "cn" : "linux01" }).count() -
Remove all
ldap_storerecords of the system:db.ldap_store.deleteMany({ "cn" : "linux01" })
Allow RSA Keys on Ubuntu 22.04 or Later
-
Add the following line to the bottom of the
/etc/ssh/sshd_configfile:PubkeyAcceptedKeyTypes +ssh-rsa -
Restart
sshd:sudo systemctl restart sshd