diff -Naur opensc-0.9.6.debian/debian/changelog opensc-0.9.6/debian/changelog
--- opensc-0.9.6.debian/debian/changelog	2005-08-08 14:12:29.751064980 +1000
+++ opensc-0.9.6/debian/changelog	2005-08-08 14:11:46.384658902 +1000
@@ -1,3 +1,9 @@
+opensc (0.9.6-2.1) unstable; urgency=low
+
+  * Modify PAM module to add card to agent.
+
+ -- Brendan O'Dea <bod@debian.org>  Mon,  8 Aug 2005 14:11:28 +1000
+
 opensc (0.9.6-2) unstable; urgency=low
 
   * The "RTFM" release.
diff -Naur opensc-0.9.6.debian/debian/control opensc-0.9.6/debian/control
--- opensc-0.9.6.debian/debian/control	2005-08-08 14:12:29.747065680 +1000
+++ opensc-0.9.6/debian/control	2005-08-08 14:10:37.303771285 +1000
@@ -2,7 +2,7 @@
 Priority: extra
 Section: utils
 Maintainer: Eric Dorland <eric@debian.org>
-Build-Depends: cdbs, debhelper (>> 4.1.0), libssl-dev (>= 0.9.7d-3), libpcsclite-dev (>= 1.2.9-beta1), libpam0g-dev, libldap-dev, libassuan-dev (>= 0.6.4-2), libopenct1-dev, libxt-dev, flex, pkg-config
+Build-Depends: cdbs, debhelper (>> 4.1.0), libssl-dev (>= 0.9.7d-3), libpcsclite-dev (>= 1.2.9-beta1), libpam0g-dev, libldap-dev, libassuan-dev (>= 0.6.4-2), libopenct1-dev, libxt-dev, flex, pkg-config, libssh-dev
 Standards-Version: 3.6.1
 
 Package: opensc
@@ -98,4 +98,4 @@
  A plugin for mozilla that allows S/MIME and SSL authentication using
  OpenSC.
  .
- Card initialization can be performed by utilities in the opensc package. 
\ No newline at end of file
+ Card initialization can be performed by utilities in the opensc package. 
diff -Naur opensc-0.9.6.debian/debian/libopensc1.shlibs opensc-0.9.6/debian/libopensc1.shlibs
--- opensc-0.9.6.debian/debian/libopensc1.shlibs	2005-08-08 14:12:29.748065505 +1000
+++ opensc-0.9.6/debian/libopensc1.shlibs	2005-08-08 14:10:37.304771109 +1000
@@ -1,4 +1,4 @@
 libopensc       1 libopensc1 (>> 0.9.6)
 libpkcs15init   1 libopensc1 (>> 0.9.6)
 libscconf       1 libopensc1 (>> 0.9.6)
-libpkcs11       1 libopensc1 (>> 0.9.6)
\ No newline at end of file
+libpkcs11       1 libopensc1 (>> 0.9.6)
diff -Naur opensc-0.9.6.debian/debian/rules opensc-0.9.6/debian/rules
--- opensc-0.9.6.debian/debian/rules	2005-08-08 14:12:29.762063054 +1000
+++ opensc-0.9.6/debian/rules	2005-08-08 14:10:52.549087607 +1000
@@ -7,4 +7,4 @@
 
 DEB_SHLIBDEPS_INCLUDE := debian/tmp/usr/lib debian/tmp/usr/lib/pkcs11
 
-DEB_CONFIGURE_SYSCONFDIR := /etc/opensc
\ No newline at end of file
+DEB_CONFIGURE_SYSCONFDIR := /etc/opensc
diff -Naur opensc-0.9.6.debian/src/pam/Makefile.am opensc-0.9.6/src/pam/Makefile.am
--- opensc-0.9.6.debian/src/pam/Makefile.am	2005-03-24 08:12:15.000000000 +1100
+++ opensc-0.9.6/src/pam/Makefile.am	2005-08-08 14:10:52.550087431 +1000
@@ -4,7 +4,7 @@
 
 MAINTAINERCLEANFILES = Makefile.in
 
-INCLUDES = @CPPFLAGS@ -I${top_srcdir}/src/scam
+INCLUDES = @CPPFLAGS@ -I${top_srcdir}/src/scam -I/usr/include/ssh
 
 AM_LDFLAGS = ${top_builddir}/src/scam/libscam.la
 
@@ -15,6 +15,8 @@
 
 pam_opensc_la_SOURCES = pam_opensc.c pam_support.c pam_support.h
 pam_opensc_la_LDFLAGS = -module -avoid-version
+pam_opensc_la_LIBADD = -lssh -lopenbsd-compat
 
 test_pam_SOURCES = test-pam.c misc_conv.c
 test_pam_LDFLAGS = @LDFLAGS@ @LIBDL@ @LIBPAM@
+test_pam_LDADD = -lssh -lopenbsd-compat
diff -Naur opensc-0.9.6.debian/src/pam/Makefile.in opensc-0.9.6/src/pam/Makefile.in
--- opensc-0.9.6.debian/src/pam/Makefile.in	2005-04-26 06:39:59.000000000 +1000
+++ opensc-0.9.6/src/pam/Makefile.in	2005-08-08 14:10:52.551087255 +1000
@@ -198,7 +198,7 @@
 
 MAINTAINERCLEANFILES = Makefile.in
 
-INCLUDES = @CPPFLAGS@ -I${top_srcdir}/src/scam
+INCLUDES = @CPPFLAGS@ -I${top_srcdir}/src/scam -I/usr/include/ssh
 
 AM_LDFLAGS = ${top_builddir}/src/scam/libscam.la
 
@@ -207,9 +207,11 @@
 
 pam_opensc_la_SOURCES = pam_opensc.c pam_support.c pam_support.h
 pam_opensc_la_LDFLAGS = -module -avoid-version
+pam_opensc_la_LIBADD = -lssh -lopenbsd-compat
 
 test_pam_SOURCES = test-pam.c misc_conv.c
 test_pam_LDFLAGS = @LDFLAGS@ @LIBDL@ @LIBPAM@
+test_pam_LDADD = -lssh -lopenbsd-compat
 subdir = src/pam
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -217,7 +219,7 @@
 CONFIG_CLEAN_FILES =
 LTLIBRARIES = $(lib_LTLIBRARIES)
 
-pam_opensc_la_LIBADD =
+pam_opensc_la_DEPENDENCIES =
 am_pam_opensc_la_OBJECTS = pam_opensc.lo pam_support.lo
 pam_opensc_la_OBJECTS = $(am_pam_opensc_la_OBJECTS)
 @HAVE_PAM_TRUE@noinst_PROGRAMS = test-pam$(EXEEXT)
@@ -226,7 +228,6 @@
 
 am_test_pam_OBJECTS = test-pam.$(OBJEXT) misc_conv.$(OBJEXT)
 test_pam_OBJECTS = $(am_test_pam_OBJECTS)
-test_pam_LDADD = $(LDADD)
 test_pam_DEPENDENCIES =
 
 DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
diff -Naur opensc-0.9.6.debian/src/pam/pam_opensc.c opensc-0.9.6/src/pam/pam_opensc.c
--- opensc-0.9.6.debian/src/pam/pam_opensc.c	2005-03-24 08:12:15.000000000 +1100
+++ opensc-0.9.6/src/pam/pam_opensc.c	2005-08-08 14:10:52.553086903 +1000
@@ -33,6 +33,9 @@
 #include "pam_support.h"
 #include "scam.h"
 
+#include <key.h>
+#include <authfd.h>
+
 #define PAM_SM_AUTH
 #define PAM_SM_ACCOUNT
 #define PAM_SM_SESSION
@@ -208,6 +211,11 @@
 		return PAM_AUTH_ERR;
 	}
 	opensc_pam_log(LOG_INFO, pamh, "Authentication successful for %s at %s.\n", user, tty);
+	AuthenticationConnection *auth = ssh_get_authentication_connection();
+	if (auth) {
+	    ssh_update_card(auth, 1, "0", password, 0, 0);
+	    ssh_close_authentication_connection(auth);
+	}
 	return PAM_SUCCESS;
 }
 
