--- sshlpd.orig 2007-02-13 15:44:52.000000000 -0500 +++ sshlpd 2007-02-13 15:54:48.000000000 -0500 @@ -30,8 +30,9 @@ # # http://www.linuxprinting.org/beh.html -my $SSH_PASSWORD_DIRECTORY = '/etc/sshpassword'; -my $TIMEOUT = 10; +# Note that this particular copy of sshlpd has been patched to use key-based authentication. +# Thanks to Stephen DeGabriele for the changes. + # TODO would be nice if we didn't have to specify the location of lpr my $REMOTE_LPR = '/usr/ucb/lpr'; @@ -103,23 +104,10 @@ my $whoami = `whoami`; chomp $whoami; -my $passwordFile = "$SSH_PASSWORD_DIRECTORY/$connectToString"; -open(PASSWORD_FILE, '<', $passwordFile) or dieCleanly(qq#No password info for "$connectToString"; create "$passwordFile" and make sure it is readable by user $whoami (but not by other users, or they will be able to see your password!).\n#); -my $password = ; chomp $password; -close(PASSWORD_FILE); - for(my $i = 0; $i < $copies; $i++) { my $command = qq#ssh '$connectToString' '$REMOTE_LPR -P "$destination" -T "$jobTitle"' < '$printFile'#; - my $expect = Expect->spawn($command) or dieCleanly("Cannot spawn ssh process: $!\n"); - - $expect->expect($TIMEOUT, - [ qr/.*password: / => sub { my $exp = shift; $exp->send("$password\n"); exp_continue; } ] - ); - - $expect->soft_close(); - - dieCleanly(qq#ssh returned $? ($i of $copies copies printed): $!\nTry running "ssh $connectToString" as user $whoami (try running "sudo -u $whoami ssh $connectToString" as root) and see if it works.\nThere are at least two potential problems, both relating to host keys.\nFirst, you may simply need to accept the host key.\nIf so, once you have accepted the key, you should be able to print.\nIf that doesn't work, then it may be the case that $whoami has no home directory and thus nowhere to save the keys.\nIf so, you'll have to create a home directory for $whoami.\nTry "grep $whoami /etc/passwd"; the sixth field in ${whoami}'s column is the home directory.\nAs root, create it and change the owner to $whoami with "chown ${whoami}:${whoami} ".\nThen run the ssh command listed above again, accepting the host key, and try printing again.\n#) if $expect->exitstatus(); + system($command) == 0 or dieCleanly(qq#ssh returned $?: $!\nMake sure that key-based authentication is set up for ssh.\nYou might try running "sudo -u $whoami ssh $connectToString" as root.\nIt should not ask you to accept a host key or enter a password.\nNote that ssh will be run as $whoami.\nMake sure that your ssh configuration exists in that user's home directory.\nAlso be sure that your ssh server is configured properly.\n#); } cleanUp();