Network Attack Defense: SSH PKI authentication on endpoint connections
Network Attack Defense protection for SSH uses a modified version of libssh to proxy client connections to the product, which then connects to the remote server. Client-product and product-remote server connections are only established at the transport layer.
Before accepting connections, the proxy initializes its server by loading the SSH keys in /opt/bitdefender-security-tools/etc/ssh.
It tries ssh_host_rsa_key, ssh_host_ed25518_key and finally ssh_host_ecdsa_key.
The first one that is found will be used. However, if none is found, a completely new pair of keys is automatically generated and the RSA one is used.
The directory layout of /opt/bitdefender-security-tools/etc/ssh is a copy of the one found on VMware ESXi (5.0 and later). Additionally, for each user in /opt/bitdefender-security-tools/etc/ssh/keys-$user, besides the private keys, an authorized_keys file can be configured. This will be required if the proxy manages to authenticate to the remote host using one of the user private keys.
Check the following directory layout example:
# ls -lR etc/ssh/ etc/ssh/: total 24 drwxr-xr-x. 2 root bitdefender 58 Oct 11 15:47 keys-root drwxr-xr-x. 2 root bitdefender 58 Oct 11 15:50 keys-test -rw-------. 1 root bitdefender 241 Oct 6 02:42 ssh_host_ecdsa_key -rw-------. 1 root bitdefender 180 Oct 6 02:42 ssh_host_ecdsa_key.pub -rw-------. 1 root bitdefender 395 Oct 6 02:42 ssh_host_ed25519_key -rw-------. 1 root bitdefender 100 Oct 6 02:42 ssh_host_ed25519_key.pub -rw-------. 1 root bitdefender 3272 Oct 6 02:42 ssh_host_rsa_key -rw-------. 1 root bitdefender 744 Oct 6 02:42 ssh_host_rsa_key.pub etc/ssh/keys-root: total 12 -rw-------. 1 root bitdefender 400 Oct 11 15:47 authorized_keys -rw-------. 1 root bitdefender 1679 Oct 22 2021 id_rsa -rw-------. 1 root bitdefender 400 Oct 22 2021 id_rsa.pub etc/ssh/keys-test: total 12 -rw-------. 1 root bitdefender 400 Oct 11 15:50 authorized_keys -rw-------. 1 root bitdefender 1679 Oct 11 15:50 id_rsa -rw-------. 1 root bitdefender 400 Oct 11 15:50 id_rsa.pub
The authentication flow is as follows:
The proxy advertises the none authentication method to the client in order to capture the user name.
The proxy initializes the connection to the remote server.
The proxy loads all private keys found in
/etc/ssh/keys-$user(if any).If none of the user’s private keys could be used to authenticate to the remote server or if the PKI authentication with the client failed, the proxy enters MITM mode in order to give the client the chance to try password authentication directly.
Configuring authentication with SSH keys when Network Attack Defense is enabled
When Network Attack Defense and SSH/SCP traffic inspection are enabled, additional configuration is required for environments that use SSH key-based authentication (PKI).
Follow the procedure that applies to your use case.
Important
All commands in the following procedures must be executed on the endpoint where BEST is installed.
In the following procedures, the BEST installation directory is assumed to be
/opt/bitdefender-security-tools.
Outgoing SSH connections
Use this procedure if the protected endpoint initiates SSH or SCP connections to remote servers:
Create the
/opt/bitdefender-security-tools/etc/ssh/keys-$userdirectory, where$useris the username used to authenticate to the remote server, if it does not already exist.Move the SSH key pair used to authenticate to the remote server in the previously created directory.
Use
ssh-keygento generate a new SSH key pair for the user on the protected endpoint.Create the
authorized_keysfile in the same/opt/bitdefender-security-tools/etc/ssh/keys-$userdirectory, if it does not already exist.Append the public key (
*.pub) previously generated to theauthorized_keysfile created earlier.
Consider the following setup:
The protected endpoint has a local user named
local.The remote server has a user named
remote.The connection is initiated from the protected endpoint:
ssh remote@remote-server
To configure SSH key authentication:
Create the directory
/opt/bitdefender-security-tools/etc/ssh/keys-remote/if it does not already exist.Move the SSH key pair used to authenticate to the remote server into the previously created directory.
Generate a new SSH key-pair for the user
localusingssh-keygen.Create the
/opt/bitdefender-security-tools/etc/ssh/keys-remote/authorized_keysfile if it does not already exist.Append the public key generated at step 3 to the previously created file.
Incoming SSH connections
Use this procedure if remote clients initiate SSH or SCP connections to the protected endpoint:
Create the
/opt/bitdefender-security-tools/etc/ssh/keys-$userdirectory, where$useris the account that remote clients use to authenticate to the protected endpoint, if it does not already exist.In the newly created directory, create the
authorized_keysfile.Copy the contents of the target user's existing
authorized_keysfile (typically located in~/.ssh) into the previously created file.Generate a new SSH key pair for
$userand store it in/opt/bitdefender-security-tools/etc/ssh/keys-$user.Append the public key generated at the previous step to the
authorized_keysfile on the protected endpoint, typically located in~/.ssh.This allows the Network Attack Defense SSH proxy to authenticate to the local SSH service on behalf of the user.
Consider the following setup:
The protected endpoint has a local user named
local.A remote client connects to the protected endpoint using:
ssh local@protected-endpoint
To configure SSH key authentication:
Create the
/opt/bitdefender-security-tools/etc/ssh/keys-localdirectory if it does not already exist.Create the
/opt/bitdefender-security-tools/etc/ssh/keys-local/authorized_keysfile if it does not already exist.Copy the contents of the existing
~/.ssh/authorized_keysfile into the previously created file.Generate a new SSH key pair and store it in
/opt/bitdefender-security-tools/etc/ssh/keys-local/.Example:
ssh-keygen -t ed25519 -f /opt/bitdefender-security-tools/etc/ssh/keys-local/id_ed25519
Append the public key previously generated to the
~/.ssh/authorized_keysfile.