#!/usr/bin/perl use warnings; use strict; use Net::LDAP; use File::Slurp; my $people_ou = "ou=People,dc=mageia,dc=org"; my $login = "uid=$ARGV[0],$people_ou"; print "enter password for $login : "; my $password = ; chomp($password); my $ldap = Net::LDAP->new( 'ldap.mageia.org', scheme => "ldaps"); my $mesg = $ldap->bind( $login, password => $password ); foreach my $auth (glob('/home/*/.ssh/authorized_keys')) { $auth =~ m|/home/(.*)/.ssh|; my $username = $1; foreach my $key (read_file($auth)) { chomp($key); next if $key =~ /^$/; $mesg = $ldap->modify( "uid=$username,$people_ou", changes => [ add => [ sshPublicKey => "$key" ], ]); } } print "\n"; # pour tout les users # faire un cat du fichier # pour chaque ligne # ajouter un champ