Local privilege 2FA with SSH Keys
Local Privileges Account 2FA
Local privileged accounts can have 2FA enabled, which uses an SSH key or password as the first factor and a DID as the second factor. It sends a login request to the wallet to which the endpoint user credential has been shared. Read more on how to assign endpoint user credentials to a wallet, which, when approved, authenticates the user into an endpoint. Read more on accepting login requests from wallet.
Local users can be configured to have a password or SSH keys as the first factor, coupled with a DID as the second factor.
Configuring Local Privileged Account for Logging via SSH Keys
Generating Keys for SSH Login
-
Use the command:
ssh-keygen
-
To transfer keys, use the command below:
cat ~/.ssh/id_rsa.pub | ssh username@ipaddress "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
Configuring AuthNull PAM Authenticator for SSH Login
-
Log in to any VM and check out the
pam.so
file anddid.sh
script from this GitHub link. -
Move the
pam_authenticator.so
file into the/usr/local/lib/security
path (if the “security” folder is not available, create it), and also movedid.sh
to the root (/
) path (provide the correct permissions if required). -
Add the lines below at the end of the
/etc/pam.d/sshd
file:auth required /usr/local/lib/security/pam_authenticator.so debug nullok
auth required pam_permit.so
# Comment @include common-auth - This will exclude /etc/pam.d/common-auth file -
For SSH Key authentication:
Add the lines below at the end of the
sshd_config
file. Path:/etc/ssh/sshd_config
AuthenticationMethods publickey,keyboard-interactive
KbdInteractiveAuthentication yes -
Restart the SSH service:
sudo systemctl restart sshd
-
Now log in to the VM using SSH:
ssh username@ipaddress
a. Enter the passphrase for the private key (make sure the public key is placed inside the
$HOME/.ssh/authorized_keys
path).b. Passwordless 2nd factor authentication will be initiated. Check the logs from
/var/log/auth.log
(for Ubuntu-based systems) or/var/log/secure
(for CentOS-based systems). -
The following are issues you may encounter while running the
.so
file from logs:a. PAM (header) not found
-
On CentOS and RHEL VMs, install the
pam-devel
package:sudo yum install pam-devel
-
On Debian/Ubuntu VMs, install
libpam0g-dev
:sudo apt-get install libpam0g-dev
b. Autoconf not installed/found
sudo apt-get install autoconf automake gdb git libffi-dev zlib1g-dev libssl-dev
(For Debian/Ubuntu)
-
Note: To ignore any user group without using AuthNull's custom PAM authentication, configure the following in /etc/pam.d/sshd
(this will exclude users in the group {group_name}
from logging in with MFA PAM):
auth [success=done default=ignore] pam_succeed_if.so user ingroup group_name