Setup Linux Client machine

Hi Guys,

It’s my firt time using Privacyidea and I have a very simple question for who can help.
I have installed a PrivaryIdea server and a Openldap server. Openldap is a realm and I can authenticate on PrivacyIdea GUI using LDAP users. Now I have a third linux server that I want to connect to privacyIdea box for SSH authentication. I’ve try to configure my client to authenticate to a normal ldap server but port 389 is not listning on Privacyidea box. I can’t understand if I can use the Privacy_pam module or if I need additionaly to set up a freeradius. I’m a bit confused. Can you help me pls?

Thanks in advanced

Ricardo

Hi Ricardo,

welcome to privacyIDEA.
An application has different possibilities to use privacyIDEA for authentication.

Your application, that wants to use privacyIDEA for 2FA, is the SSH server.
The SSH server will use the PAM stack for authentication.

So you have two possibilities to talk to privacyIDEA:

A) privacyidea_pam
You can use the privacyIDEA PAM module which communitcates to privacyIDEA directly via the https REST API against the endpoint /validate/check.
You would do this, if privacyidea_pam works out for you well and if you do not need RADIUS at any other point.

B) RADIUS
You can use the freeradius pam module, that comes with the distribution of your SSH server.
In this case you have to install the FreeRADIUS with the privacyIDEA RADIUS plugin on the privacyIDEA machine.
The PAM stack will communicate via the RADIUS protocol to FreeRADIUS, which will pass the request to privacyIDEA (via the REST API).
You will choose this one, if it is easier for you to setup the default pam_radius on the SSH machine and if you can use the RADIUS server for other purposes like VPN…

Have fun!
Cornelius

Hi Cornelius,

Thank you for your quick and clear answer. I’ve googled the www searching how to install privacyIDEA pam module on CentOS and I haven´t found any repo with it. Is it available only for Ubunto flavour?

regards,

Ricardo

Hi Ricardo,

The source of the pam module can be found here:

regards

I believe I also have to install pam_python right? I mean. I allready intalled pam_python_master from the above link but it is giving the error that the pam_python is missing:

PAM unable to dlopen(/usr/lib64/security/pam_python.so): /usr/lib64/security/pam_python.so: cannot open shared object file

Do I install pam_python using pip also?

This should come with your distribution.
This is the distributions C pam_python module, which is the wrapper for our privacyidea-python-pam-module.

I have install it the pam_module on https://github.com/privacyidea/pam_python and added auth requisite pam_python.so /path/to/modules/privacyidea-pam.py but I had the error “PAM unable to dlopen(/usr/lib64/security/pam_python.so): /usr/lib64/security/pam_python.so: cannot open shared object file”. I than installed pam_python pam-python-1.0.6-1 and the error is gone. But seems like pam module is never called to authentication. I add the following lines on the authentication files:

/etc/pam.d/sshd:

#%PAM-1.0
auth required pam_sepermit.so
auth substack password-auth
auth include postlogin
auth requisite pam_python.so /usr/lib/python3.4/site-packages/privacyidea_pam-2.11.dev0-py3.4.egg/

-auth optional pam_reauthorize.so prepare
account required pam_nologin.so
account include password-auth
password include password-auth
session required pam_selinux.so close
session required pam_loginuid.so
session required pam_selinux.so open env_params
session required pam_namespace.so
session optional pam_keyinit.so force revoke
session include password-auth
session include postlogin
-session optional pam_reauthorize.so prepare

password-auth:

#%PAM-1.0
#This file is auto-generated.
#User changes will be destroyed the next time authconfig is run.
#auth requisite pam_python.so /usr/lib/python3.4/site-packages/privacyidea_pam-2.11.dev0-py3.4.egg/
auth required pam_env.so
auth required pam_faildelay.so delay=2000000
auth required pam_faillock.so preauth silent deny=3 unlock_time=never fail_interval=900
auth sufficient pam_unix.so try_first_pass
auth requisite pam_succeed_if.so uid >= 1000 quiet_success
auth required pam_deny.so

account required pam_faillock.so
account required pam_unix.so
account sufficient pam_localuser.so
account sufficient pam_succeed_if.so uid < 1000 quiet
account required pam_permit.so

password requisite pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type=
password sufficient pam_unix.so sha512 shadow try_first_pass use_authtok

auth required pam_faillock.so authfail deny=3 unlock_time=never fail_interval=900

password required pam_deny.so

session optional pam_keyinit.so revoke
session required pam_limits.so
-session optional pam_systemd.so
session optional pam_mkhomedir.so umask=0077
session [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session required pam_unix.so

And on sshd logs I got:

Aug 28 10:45:59 stldnrspapp01 sshd[26895]: debug1: Forked child 26928.
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: Set /proc/self/oom_score_adj to 0
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: rexec start in 5 out 5 newsock 5 pipe 7 sock 8
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: rexec line 169: Deprecated option RhostsRSAAuthentication
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: inetd sockets after dupping: 3, 3
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: Connection from 10.21.197.209 port 54305 on 10.21.197.211 port 22
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: Client protocol version 2.0; client software version MoTTY_Release_0.36
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: no match: MoTTY_Release_0.36
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: Local version string SSH-2.0-OpenSSH_7.4
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: Enabling compatibility mode for protocol 2.0
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: SELinux support enabled [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: permanently_set_uid: 74/74 [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: list_hostkey_types: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: SSH2_MSG_KEXINIT sent [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: SSH2_MSG_KEXINIT received [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: kex: algorithm: diffie-hellman-group-exchange-sha256 [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: kex: host key algorithm: ssh-ed25519 [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: kex: client->server cipher: aes256-ctr MAC: hmac-sha2-256 compression: none [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: kex: server->client cipher: aes256-ctr MAC: hmac-sha2-256 compression: none [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: kex: diffie-hellman-group-exchange-sha256 need=32 dh_need=32 [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: kex: diffie-hellman-group-exchange-sha256 need=32 dh_need=32 [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: expecting SSH2_MSG_KEX_DH_GEX_REQUEST [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: SSH2_MSG_KEX_DH_GEX_REQUEST received [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: SSH2_MSG_KEX_DH_GEX_GROUP sent [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: expecting SSH2_MSG_KEX_DH_GEX_INIT [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: rekey after 4294967296 blocks [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: SSH2_MSG_NEWKEYS sent [preauth]
Aug 28 10:45:59 stldnrspapp01 sshd[26928]: debug1: expecting SSH2_MSG_NEWKEYS [preauth]
Aug 28 10:46:00 stldnrspapp01 sshd[26928]: debug1: SSH2_MSG_NEWKEYS received [preauth]
Aug 28 10:46:00 stldnrspapp01 sshd[26928]: debug1: rekey after 4294967296 blocks [preauth]
Aug 28 10:46:00 stldnrspapp01 sshd[26928]: debug1: KEX done [preauth]
Aug 28 10:46:00 stldnrspapp01 sshd[26928]: debug1: userauth-request for user rsilva service ssh-connection method none [preauth]
Aug 28 10:46:00 stldnrspapp01 sshd[26928]: debug1: attempt 0 failures 0 [preauth]
Aug 28 10:46:00 stldnrspapp01 sshd[26928]: reprocess config line 169: Deprecated option RhostsRSAAuthentication
Aug 28 10:46:00 stldnrspapp01 sshd[26928]: Invalid user rsilva from 10.21.197.209 port 54305
Aug 28 10:46:00 stldnrspapp01 sshd[26928]: input_userauth_request: invalid user rsilva [preauth]
Aug 28 10:46:00 stldnrspapp01 sshd[26928]: debug1: PAM: initializing for “rsilva”
Aug 28 10:46:00 stldnrspapp01 sshd[26928]: debug1: PAM: setting PAM_RHOST to “gateway”
Aug 28 10:46:00 stldnrspapp01 sshd[26928]: debug1: PAM: setting PAM_TTY to “ssh”
Aug 28 10:46:00 stldnrspapp01 sshd[26928]: debug1: userauth_send_banner: sent [preauth]
Aug 28 10:46:03 stldnrspapp01 sshd[26928]: debug1: userauth-request for user rsilva service ssh-connection method password [preauth]
Aug 28 10:46:03 stldnrspapp01 sshd[26928]: debug1: attempt 1 failures 0 [preauth]

can you help me on this?
I’ve also filled the form to ask for a quote on Privacyidea site but havent received any reply yet

bet regards,

Ricardo

ssh it’s beeing called but is givving this error:

Aug 29 16:24:20 stldnrspapp01 sshd[14427]: debug1: PAM: initializing for “rsilva”
Aug 29 16:24:20 stldnrspapp01 sshd[14427]: debug1: PAM: setting PAM_RHOST to “gateway”
Aug 29 16:24:20 stldnrspapp01 sshd[14427]: debug1: PAM: setting PAM_TTY to “ssh”
Aug 29 16:24:20 stldnrspapp01 sshd[14427]: debug1: userauth_send_banner: sent [preauth]
Aug 29 16:24:37 stldnrspapp01 sshd[14427]: debug1: userauth-request for user rsilva service ssh-connection method password [preauth]
Aug 29 16:24:37 stldnrspapp01 sshd[14427]: debug1: attempt 1 failures 0 [preauth]
Aug 29 16:24:37 stldnrspapp01 sshd[14427]: privacyidea_pam: running try_first_pass
Aug 29 16:24:37 stldnrspapp01 sshd[14427]: Traceback (most recent call last):
le “/usr/lib/python3.4/site-packages/privacyidea_pam-2.11.dev0-py3.4.egg/privacyidea_pam.py”, line 329, in pam_sm_authenticate
rval = Auth.authenticate(pamh.authtok)
File “/usr/lib/python3.4/site-packages/privacyidea_pam-2.11.dev0-py3.4.egg/privacyidea_pam.py”, line 140, in authenticate
r, serial = check_offline_otp(self.user, password, self.sqlfile, window=10)
File “/usr/lib/python3.4/site-packages/privacyidea_pam-2.11.dev0-py3.4.egg/privacyidea_pam.py”, line 389, in check_offline_otp
conn = sqlite3.connect(sqlfile)
** OperationalError: unable to open database file
Aug 29 16:24:37 stldnrspapp01 sshd[14427]: privacyidea_pam: unable to open database file
Aug 29 16:24:37 stldnrspapp01 sshd[14427]: pam_unix(sshd:auth): check pass; user unknown
Aug 29 16:24:37 stldnrspapp01 sshd[14427]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=gateway
Aug 29 16:24:40 stldnrspapp01 sshd[14427]: debug1: PAM: password authentication failed for an illegal user: User not known to the underlying authentication module
Aug 29 16:24:40 stldnrspapp01 sshd[14427]: Failed password for invalid user rsilva from 10.21.197.209 port 49512 ssh2

can you help me trobleshooting this please?
Why do I need a local DB on the client machine?

The sqlite file is needed so that the privacyidea pam can store offline authentication information.

A

mkdir -p /etc/privacyidea
touch /etc/privacyidea/pam.sqlite

should do.

Please note two things:

  1. privacyidea-pam is not tested with Python 3.

  2. the code should create the database table (in the newly created empty file) here (https://github.com/privacyidea/pam_python/blob/master/privacyidea_pam.py#L391). But for this the file of course must be writable for the PAM process.

I’m running on python 3 because I was having some syntaxe errors on the pam molule on 2.x. I’ll try it again.

thks

OK, I’ve removed python3.4 and installed python-setuptools. Now I was able to install the pam module:

python setup.py install

Installed /usr/lib/python2.7/site-packages/privacyidea_pam-2.11dev0-py2.7.egg
Processing dependencies for privacyidea-pam==2.11dev0
Finished processing dependencies for privacyidea-pam==2.11dev0

I correct the path on the pam.d file but the error looks very similar. It appears it is not creating the DB structure on the empty file created:

Sep 02 14:55:18 stldnrspapp01 sshd[24822]: privacyidea_pam: running try_first_pass
Sep 02 14:55:18 stldnrspapp01 sshd[24822]: Traceback (most recent call last):
File “/usr/lib/python2.7/site-packages/privacyidea_pam-2.11dev0-py2.7.egg/privacyidea_pam.py”, line 329, in pam_sm_authenticate
rval = Auth.authenticate(pamh.authtok)
File “/usr/lib/python2.7/site-packages/privacyidea_pam-2.11dev0-py2.7.egg/privacyidea_pam.py”, line 140, in authenticate
r, serial = check_offline_otp(self.user, password, self.sqlfile, window=10)
File “/usr/lib/python2.7/site-packages/privacyidea_pam-2.11dev0-py2.7.egg/privacyidea_pam.py”, line 396, in check_offline_otp
“GROUP by serial”, (user,)):
OperationalError: no such table: authitems
Sep 02 14:55:18 stldnrspapp01 sshd[24822]: privacyidea_pam: no such table: authitems
Sep 02 14:55:18 stldnrspapp01 sshd[24822]: pam_unix(sshd:auth): check pass; user unknown
Sep 02 14:55:18 stldnrspapp01 sshd[24822]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=gateway
Sep 02 14:55:19 stldnrspapp01 sshd[24822]: debug1: PAM: password authentication failed for an illegal user: User not known to the underlying authentication module

Were do I follow troubleshooting?

regards

ok, i Got it. I’ve to troubleshoot the python pam and found that selinux was not permiting the file to be created. almost done to get my PoC working. Now my user from ldap realm, using a HOTP token is giving a wrong PIN error. I read that from default offline authentication expectes pin+token. The test on the token site works fine but not when debuging authentication on Privacyidead appliance:

[DEBUG][privacyidea.lib.token:197] Exiting check_token_list with result (False, {‘message’: ‘wrong otp pin’})
Entering get_action_values with arguments (<privacyidea.lib.policy.PolicyClass object at 0x7f80489ee910>,) and keywords {‘realm’: u’ldap_rsp’, ‘client’: ‘10.21.197.211’, ‘user’: u’rsilva’, ‘resolver’: u’ldapserver’, ‘action’: ‘auth_max_success’, ‘scope’: ‘authorization’, ‘unique’: True}

not sure what’s wrong now!!! Is it a policy missing?

regards

1 Like

Your PIN is wrong. That we know. But how should we know why?

It depends on your authentication policies and on what you enter at the authentication step.
Note, that in the PAM stack you have to enter “PIN+OTP” in one step.

Please tell which authentication policies you have defined!

Hi Corneliux,

I’m using pin+otp. My PIN is “res” and when I test the authentication on “test token” I see in the log file:

[2019-09-03 17:39:28,499][1078][140189334759168][DEBUG][privacyidea.models:361] hPin: 78158997f73a33d0faa0091143969cfa9a4935008a1068049b5640d38c31321a, pin: u’res’, seed: 294f1567610ab6241eb8fdc0017f76b7

when I’m tryng to authenticate from other server I get:

[2019-09-03 17:37:44,532][1078][140189334759168][DEBUG][privacyidea.models:361] hPin: 3727404d3ae6a5e06428cf80db9a0d1950b01186f2ccfe762c986de4e5a1cab2, pin: u’\x08\n\r’, seed: 294f1567610ab6241eb8fdc0017f76b7

That is why it is sayng the otp pin is wrong even doe I type it correctly. Any idea why?

regards,

Ricardo

Any chance the keyboards are different between those computers?

Ok, there are not the same as I thought:

Client:

System Locale: LANG=en_GB.UTF-8
VC Keymap: gb
X11 Layout: gb

Privacyidea Server:

System Locale: LANG=en_GB.UTF-8
LANGUAGE=en_GB:en
VC Keymap: n/a
X11 Layout: pt
X11 Model: pc105

but pin “res” or “1234” should be the sabe for both keyboards

now they match but I still have the same problem

Client:

System Locale: LANG=en_GB.UTF-8
VC Keymap: gb
X11 Layout: gb

Server:

System Locale: LANG=en_GB.UTF-8
LANGUAGE=en_GB:en
VC Keymap: gb
X11 Layout: gb

[2019-09-04 16:57:07,464][1072][140034429912832][DEBUG][privacyidea.models:361] hPin: 3727404d3ae6a5e06428cf80db9a0d1950b01186f2ccfe762c986de4e5a1cab2, pin: u ‘\x08\n\r’, seed: 294f1567610ab6241eb8fdc0017f76b7

Pin was “res”

I’ve installed a second client server, this time I did not install nothing from python 3 and the machine is trying to validate the otp pin with Privacyidea server. The otp pin is always wrong, because is delivered on the same wrong format. Any idea guys?

Does anyone knows if privacyidea pam module works well on python v2.7.5?