#!/usr/bin/perl -w use strict; our (%users, %linenos); &usage unless $ARGV[0] and -f $ARGV[0]; my @authlines = &filelines($ARGV[0]); my $lineno = 0; for (@authlines) { $lineno++; if (/^# gitolite start/ .. /^# gitolite end/) { warn "line $lineno: non-gitolite key found in gitolite section" if /ssh-rsa|ssh-dss/ and not /command=.*gl-auth-command/; } else { warn "line $lineno: gitolite key found outside gitolite section" if /command=.*gl-auth-command/; } next if /\# gitolite (start|end)/; die "line $lineno: unrecognised line\n" unless /^(?:command=".*gl-auth-command (\S+?)"\S+ )?(?:ssh-rsa|ssh-dss) (\S+)/; my ($user, $key) = ($1 || '', $2); if ($linenos{$key}) { warn "authkeys file line $lineno is repeat of line $linenos{$key}, will be ignored by server sshd\n"; next; } $linenos{$key} = $lineno; $users{$key} = ($user ? "maps to gitolite user $user" : "gets you a command line"); } print "\n"; # all *.pub in current dir should be exactly one line, starting with ssh-rsa # or ssh-dss my @pubkeys = glob("*.pub"); die "no *.pub files here\n" unless @pubkeys; for my $pub (@pubkeys) { my @lines = &filelines($pub); die "$pub has more than one line\n" if @lines > 1; die "$pub does not start with ssh-rsa or ssh-dss\n" unless $lines[0] =~ /^(?:ssh-rsa|ssh-dss) (\S+)/; my $key = $1; if ($users{$key}) { print "$pub $users{$key}\n"; } else { print "$pub has NO ACCESS to the server\n"; } } print <; } sub usage { print STDERR <