[FUG-BR] Autenticação de ssh/(s)ftp via pam_winbind

Vinicius Abrahao vinnix.bsd em gmail.com
Terça Setembro 8 12:30:57 BRT 2009


Olá Amigos, como vão?

Estou com dificuldade para fazer o ssh(SFTP) e/ou ftp(vsftpd)
funcionarem corretamente aqui,
estou utilizando um server com free e samba (instalado pelo ports),
autenticado em um PDC Windows 2003.

Pelos meus testes o samba está funcionando corretamente (e o winbind
tb), tanto que executo um comando
para buscar os dados de usuários no PDC e funcionam corretamente como esse:

# su - vinicius
$ getent passwd vinicius
vinicius:*:15000:15005::/home/UNIMETRO/vinicius:/usr/local/bin/ksh93
$ pwd
/home/UNIMETRO/vinicius

Mas não há jeito de conseguir me conectar pelo SSH.

# ssh vinicius em localhost
Password:
Password:
Password:
Permission denied (publickey,keyboard-interactive).

Meu /etc/pam.d/sshd está assim, mas já tentei várias modificações:

auth            sufficient      /usr/local/lib/pam_winbind.so   try_first_pass
auth            sufficient      pam_opie.so
no_warn no_fake_prompts
auth            required        pam_unix.so
no_warn try_first_pass

account         required        pam_nologin.so
account         sufficient      /usr/local/lib/pam_winbind.so
account         required        pam_login_access.so
account         sufficient      pam_unix.so

session         required        pam_permit.so
session         required        /usr/local/lib/pam_mkhomedir.so
session         optional        /usr/local/lib/pam_winbind.so   use_first_pass

password        sufficient      /usr/local/lib/pam_winbind.so   try_first_pass
password        required        pam_unix.so
no_warn try_first_pass


O mais engraçado é oque se passa nos logs:

* /var/log/messages
Sep  8 16:22:38 samba sshd[1927]: pam_winbind(sshd): user 'vinicius'
granted access
Sep  8 16:22:38 samba kernel: pid 1927 (sshd), uid 0: exited on signal 11

* /var/log/auth.log
Sep  8 16:22:38 samba sshd[1927]: pam_winbind(sshd): user 'vinicius'
granted access

* /var/log/debug
Sep  8 16:27:20 samba sshd[1938]: pam_winbind(sshd): getting password
(0x00000008)

E AINDA verifica-se que se eu erro a senha as mensagens de erro nos
logs são outras.
Seguindo a sugestão do Garga, coloquei o sshd em modo debug e tentei
logar pra ver oque
acontecia:


Connection from 127.0.0.1 port 60186
debug1: Client protocol version 2.0; client software version
OpenSSH_5.1p1 FreeBSD-20080901
debug1: match: OpenSSH_5.1p1 FreeBSD-20080901 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1p1 FreeBSD-20080901
debug1: permanently_set_uid: 22/22
debug1: list_hostkey_types: ssh-dss
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST received
debug1: SSH2_MSG_KEX_DH_GEX_GROUP sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_INIT
debug1: SSH2_MSG_KEX_DH_GEX_REPLY sent
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: KEX done
debug1: userauth-request for user vinicius service ssh-connection method none
debug1: attempt 0 failures 0
debug1: PAM: initializing for "vinicius"
debug1: userauth-request for user vinicius service ssh-connection
method keyboard-interactive
debug1: attempt 1 failures 0
debug1: keyboard-interactive devs
debug1: auth2_challenge: user=vinicius devs=
debug1: kbdint_alloc: devices 'pam'
debug1: auth2_challenge_start: trying authentication method 'pam'
debug1: PAM: setting PAM_RHOST to "localhost"
Postponed keyboard-interactive for vinicius from 127.0.0.1 port 60186 ssh2
debug1: do_pam_account: called
Failed keyboard-interactive/pam for vinicius from 127.0.0.1 port 60186 ssh2

debug1: userauth-request for user vinicius service ssh-connection
method keyboard-interactive
debug1: attempt 2 failures 1
debug1: keyboard-interactive devs
debug1: auth2_challenge: user=vinicius devs=
debug1: kbdint_alloc: devices 'pam'
debug1: auth2_challenge_start: trying authentication method 'pam'
Postponed keyboard-interactive for vinicius from 127.0.0.1 port 60186 ssh2
debug1: do_pam_account: called
Failed keyboard-interactive/pam for vinicius from 127.0.0.1 port 60186 ssh2

debug1: userauth-request for user vinicius service ssh-connection
method keyboard-interactive
debug1: attempt 3 failures 2
debug1: keyboard-interactive devs
debug1: auth2_challenge: user=vinicius devs=
debug1: kbdint_alloc: devices 'pam'
debug1: auth2_challenge_start: trying authentication method 'pam'
Postponed keyboard-interactive for vinicius from 127.0.0.1 port 60186 ssh2
debug1: do_pam_account: called
Failed keyboard-interactive/pam for vinicius from 127.0.0.1 port 60186 ssh2

Connection closed by 127.0.0.1
debug1: do_cleanup
debug1: do_cleanup
debug1: PAM: cleanup


Alguma luz nesse emaranhado de PAM?
Ahhh, usuários com conta local (/etc/passwd) estão se logando
normalmente via ssh.


Obrigado pessoal,
Abraços,
Vinícius


[1] http://web.irtnog.org/doc/how-to/freebsd-winbind
[2] http://www.freebsd.org/doc/en/articles/pam/pam-essentials.html
[3] http://www.ctdx.net/2008/07/11/freebsd-single-sign-on-with-active-directory-and-access-control/

Versões:

FreeBSD: amd64 7.2-STABLE FreeBSD 7.2-STABLE #1: Tue Sep  8 12:05:01 WAT 2009
Samba: 3.3.7


Mais detalhes sobre a lista de discussão freebsd