Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenVPN Performance issues with multiple users #39

Closed
Jnchi opened this issue Jun 7, 2019 · 8 comments
Closed

OpenVPN Performance issues with multiple users #39

Jnchi opened this issue Jun 7, 2019 · 8 comments
Assignees

Comments

@Jnchi
Copy link
Contributor

Jnchi commented Jun 7, 2019

Multiple users are unable to login using pam_aad in combination with the openvpn pam plugin.

I went to the device login page and it said I logged in, but OpenVPN is stuck on 'Connecting'

openvpn

See also: #14, openvpn #1194

@Jnchi
Copy link
Contributor Author

Jnchi commented Jun 7, 2019

TODO

  • Move TTW into config file

Note: The code polls Microsoft every 5 seconds, however it will wait indefinitely until either A) the token is invalid or B) the user successfully logs in.

Source: https://github.com/CyberNinjas/pam_aad/blob/master/pam_aad.c#L194

The fact that nanosleep() sleeps for a relative interval can be
problematic if the call is repeatedly restarted after being
interrupted by signals, since the time between the interruptions and
restarts of the call will lead to drift in the time when the sleep
finally completes. --http://man7.org/linux/man-pages/man2/nanosleep.2.html

@Jnchi
Copy link
Contributor Author

Jnchi commented Jun 7, 2019

@Jnchi
Copy link
Contributor Author

Jnchi commented Jun 7, 2019

The auth-pam plugin gets forked to run in background and kept
stdin/stdout/stderr open. This might block the callee of the OpenVPN
which expect that it nicely turns into a daemon.
--OpenVPN/openvpn#84

This sounds like what we are experiencing..

@Jnchi
Copy link
Contributor Author

Jnchi commented Jun 7, 2019

Reproduction Steps

  1. On the OpenVPN server, install and configure pam_aad following the instructions, then start the server and tail the logs,
tail -f /var/log/openvpn/*.log /var/log/auth.log
  1. Setup at least two OpenVPN clients, then attempt to connect the first client.

  2. After attempting to authenticate the first client via the device code, attempt to connect the second client.

Note: The second client never receives an email address.

Configuration

/etc/openvpn/server.conf

port 1194
proto udp
dev tun
dh keys/dh2048.pem
ca keys/ca.crt
cert keys/server.crt
key keys/server.key  # This file should be kept secret


;topology subnet
server 10.8.0.0 255.255.255.0
;route 10.8.0.0 255.255.255.0
ifconfig-pool-persist /var/log/openvpn/ipp.txt
keepalive 10 120

cipher AES-256-CBC
comp-lzo
persist-key
persist-tun

status /var/log/openvpn/openvpn-status.log
log         /var/log/openvpn/openvpn.log
log-append  /var/log/openvpn/openvpn.log
verb 3

;duplicate-cn
;max-clients 30
;user nobody
;group nogroup
;mute 20
;explicit-exit-notify 1

plugin /usr/lib/x86_64-linux-gnu/openvpn/plugins/openvpn-plugin-auth-pam.so openvpn
verify-client-cert optional
username-as-common-name

push "redirect-gateway def1"
;push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 208.67.220.220"
push "dhcp-option DNS 208.67.222.222"
;push "route 10.8.0.0 255.255.255.0"

/etc/openvpn/client.conf

client
dev tun
proto udp
remote 192.168.88.130 1194
resolv-retry 3
nobind
persist-key
persist-tun
ca ca.crt
cipher AES-256-CBC
comp-lzo
redirect-gateway def1
verb 3
;explicit-exit-notify 3
auth-user-pass
auth-nocache
remote-cert-tls server

/etc/pam.d/openvpn

# PAM configuration for the Secure Shell service

auth required pam_aad.so

# Standard Un*x authentication.
#@include common-auth

# Disallow non-root logins when /etc/nologin exists.
account    required     pam_nologin.so

# Uncomment and edit /etc/security/access.conf if you need to set complex
# access limits that are hard to express in sshd_config.
# account  required     pam_access.so

# Standard Un*x authorization.
@include common-account

# SELinux needs to be the first session rule.  This ensures that any
# lingering context has been cleared.  Without this it is possible that a
# module could execute code in the wrong domain.
session [success=ok ignore=ignore module_unknown=ignore default=bad]        pam_selinux.so close

# Set the loginuid process attribute.
session    required     pam_loginuid.so

# Create a new session keyring.
session    optional     pam_keyinit.so force revoke

# Standard Un*x session setup and teardown.
@include common-session

# Print the message of the day upon successful login.
# This includes a dynamically generated part from /run/motd.dynamic
# and a static (admin-editable) part from /etc/motd.
session    optional     pam_motd.so  motd=/run/motd.dynamic
session    optional     pam_motd.so noupdate

# Print the status of the user's mailbox upon successful login.
session    optional     pam_mail.so standard noenv # [1]

# Set up user limits from /etc/security/limits.conf.
session    required     pam_limits.so

# Read environment variables from /etc/environment and
# /etc/security/pam_env.conf.
session    required     pam_env.so # [1]
# In Debian 4.0 (etch), locale-related environment variables were moved to
# /etc/default/locale, so read that as well.
session    required     pam_env.so user_readenv=1 envfile=/etc/default/locale

# SELinux needs to intervene at login time to ensure that the process starts
# in the proper default security context.  Only sessions which are intended
# to run in the user's context should be run after this.
session [success=ok ignore=ignore module_unknown=ignore default=bad]        pam_selinux.so open

# Standard Un*x password updating.
@include common-password

Jnchi added a commit that referenced this issue Jun 7, 2019
Jnchi added a commit that referenced this issue Jun 7, 2019
Jnchi added a commit that referenced this issue Jun 7, 2019
This reverts commit e00fa51.

Bug: #39
Jnchi added a commit that referenced this issue Jun 7, 2019
Only attempt three times before exiting

Bug: #39
@Jnchi Jnchi self-assigned this Jun 10, 2019
@Jnchi Jnchi added the bug label Jun 10, 2019
Jnchi added a commit that referenced this issue Jun 10, 2019
Only attempt three times before exiting

Bug: #39
@Jnchi

This comment has been minimized.

@Jnchi
Copy link
Contributor Author

Jnchi commented Jun 12, 2019

Created new plugin: https://github.com/CyberNinjas/openvpn-auth-aad

@Jnchi

This comment has been minimized.

@Jnchi

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant