sshd in FreeBSD 7.1-PRE und LDAP Probleme

From: O. Hartmann <ohartman(at)zedat.fu-berlin.de>
Date: Thu, 04 Sep 2008 18:17:37 +0000

Hallo allerseits.

Nachdem vor zwei Tagen mit FreeBSD 7.1-PRE auch eine neue
OpenSSH-Version Einzug gehalten hat, funktioniert bei uns/mir die LDAP
Anbindung mit ssh/sshd nicht mehr. Ich möchte an dieser Stelle bemerken,
daß die betreffenden Client-Rechner sowie der Server alle FreeBSD
7.1-PRE fahren.

Bevor ich mein Problem beschreibe, möchte ich anmerken, daß ich die
gesamten Software, die meiner Meinung nach an diesem Prozeß beteiligt
ist, nochmals neu übersetzt habe, ohne Erfolg, es bleibt beim Alten.

Wir haben einige FreeBSD Clients, auf denen sich Benutzer anmelden
können, lokal wie über ssh. Diese Systeme sind an einen LDAP Server
angebunden. Lokal via Konsolen-Login und xdm/X11 können sich die
Benutzer problemlos einloggen, hier funktioniert die LDAP/Client
Kommunikation - allerdings nicht mit bestimmten
/etc/nsswitch.conf-Einstellungen, wie ich später bemerken werde (die
äußerst eigenartig, weil falsch und doch funktionierend sind).

Ein Login via ssh auf den betreffenden Clients funktioniert hingegen
nicht, das klappt lediglich auf genau dem Recner, auf dem auch OpenLDAP
Server läuft.

Versuche ich mich via ssh auf dem Client einzuloggen, erscheint in der
Konsole die Fehlermeldung:

hostxyz sshd[3464]: pam_ldap: error trying to bind as user "uid=...."
(Invalid credencials)
hostxyz sshd:[3464]: error: PAM: authentication error for illegal user
ohartman from foo.bar

Genau dieser User (ich) kann sich aber auf gleichem Host via
LDAP-Authentication des auf dem Host laufenden lighttpd und eben lokal
authentifizieren und anmelden.
Die oben genannte Fehlermeldung erscheint mit folgender
/etc/nsswicth.conf Einstellung, die eigentlich laut Doku gar nicht gehen
sollte, bislang aber immer klappte und auf dem Server die einzige ist,
die klappt:

passwd: compat
passwd_compat: ldap
group: compat
group_compat: ldap

Ändere ich diese beiden Attribute in die von der Doku vorgebene Version zu:

passwd: files ldap
group: files ldap

erscheint auf der Konsole des Zielhosts die Fehlermeldung

hostxyz sshd[3464]: error fatal: login_get_lastlog: Cannot find account
for uid 4711

wenn sich der User via ssh auf dieser Maschine einloggen will. Wie schon
erwähnt, lokales Login klappt problemlos! User uid=4711 bin ich und
dieser User ist exklusiv im LDAP.

Ich vermute eine äußerst nervige Fehlkonfiguration im Zusammenwirken von
SSHD und LDAP im Wechselspiel mit PAM, wobei ich verzweifelt versucht
habe, Klarheit durch Verstehen zu machen.

/etc/pam.d/sshd sieht wie folgt aus:
#
# $FreeBSD: src/etc/pam.d/sshd,v 1.16 2007/06/10 18:57:20 yar Exp $
#
# PAM configuration for the "sshd" service
#

# auth
auth sufficient pam_opie.so no_warn
no_fake_prompts
#auth requisite pam_opieaccess.so no_warn allow_local
#auth sufficient pam_krb5.so no_warn
try_first_pass
#auth sufficient pam_ssh.so no_warn
try_first_pass
auth sufficient /usr/local/lib/pam_ldap.so no_warn
auth required pam_unix.so no_warn
try_first_pass

# account
account required pam_nologin.so
#account required pam_krb5.so
account required pam_login_access.so
account sufficient /usr/local/lib/pam_ldap.so
account required pam_unix.so

# session
#session optional pam_ssh.so
session optional /usr/local/lib/pam_mkhomedir.so
skel=/usr/share/skel mode=0750
session required pam_permit.so

# password
#password sufficient pam_krb5.so no_warn
try_first_pass
password sufficient /usr/local/lib/pam_ldap.so no_warn
use_authtok
password required pam_unix.so no_warn
try_first_pass

Die Konfiguration des SSHD in /etc/ssh/sshd_config ist dergestalt:

VersionAddendum FreeBSD-20080901

Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# Disable legacy (protocol version 1) support in the server for new
# installations. In future the default will change to require explicit
# activation of protocol 1
Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 1h
ServerKeyBits 1024

# Logging
# obsoletes QuietMode and FascistLogging
SyslogFacility AUTH
LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# Change to yes to enable built-in password authentication.
PasswordAuthentication yes
#PermitEmptyPasswords no

# Change to no to disable PAM authentication
# ChallengeResponseAuthentication yes
ChallengeResponseAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to 'no' to disable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
PrintMotd yes
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no
#ChrootDirectory none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem sftp /usr/libexec/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# ForceCommand cvs server

Mir liegt derzeit näher auf FreeBSD und ssh sowie die grottenschlechte
PAM/LDAP Implementierung zu schimpfen, aber bevor ich hier enttäuscht
und verzweifelt zu Werke gehe, möchte ich hier nochmals anfragen.
Insbesondere bin ih etwas verwirrt über den Umstand, daß in
nsswitch.conf Attribute 'gunktionieren', die per Doku gar nicht
funktionieren dürften und wenn doch, äußerst schlecht bis gar nicht
dokumentiert sind.

Ich danke schon mal im voraus,

Gruß Oliver

To Unsubscribe: send mail to majordomo(at)de.FreeBSD.org
with "unsubscribe de-bsd-questions" in the body of the message
Received on Thu 04 Sep 2008 - 20:19:54 CEST

search this site