1. For remote password changes, you'll need sudo rights on the remote.
2. Ensure sudo is configured for remote root commands.
a. Edit /etc/sudoers with visudo
b. comment out the following:
#Defaults requiretty
#Defaults !visiblepw
3. Generate a new password for the user using this simple perl thingie:
Example:
[doomicon@songohan tools]$ ./genpass.pl password
$1$m/Ba1kqd$LXQxR..lqUwgWE5kSPESF0
#!/usr/bin/perl
#
# usage: genpass.pl '<password>'
# Generate MD5 encrypt string for remote useradd/usermod
# rowens
#"THE BEER-WARE LICENSE" (Revision 42):
# <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
use Crypt::PasswdMD5;
my @salt = ( '.', '/', 0 .. 9, 'A' .. 'Z', 'a' .. 'z' );
$newpass="$ARGV[0]";
sub gensalt {
my $count = shift;
my $salt;
for (1..$count) {
$salt .= (@salt)[rand @salt];
}
return $salt;
}
$encryptpass = unix_md5_crypt( $newpass, gensalt(8) );
printf "$encryptpass\n";
4. Using the password just generated, we'll use the nifty '-p' option for usermod.
ssh remote_host sudo /usr/sbin/usermod -p '$1$m/Ba1kqd$LXQxR..lqUwgWE5kSPESF0' remoteuser
If you have to change this user on multiple hosts, just loop it.
for host in `grep -v ^127 /etc/hosts | awk '{ print $1 }'`
do
ssh $host sudo /usr/sbin/usermod -p '$1$m/Ba1kqd$LXQxR..lqUwgWE5kSPESF0' user
done
Fin
Labels
1G
(41)
4G
(6)
6th edition
(1)
angron
(1)
batrep
(2)
bible
(1)
black templar
(1)
blood angels
(2)
chaos
(16)
dark angels
(7)
dark eldar
(3)
ebay
(10)
forgeworld
(1)
gamesworkshop
(1)
grampian
(1)
heyoh painting
(18)
horus heresy
(1)
linux
(3)
orks
(10)
oss
(1)
painting
(36)
pass-a-grille
(1)
phil wickham
(1)
primarch
(1)
Projects
(35)
rambling
(36)
review
(1)
rules
(3)
sailing
(4)
space wolves
(29)
tale of one gamer
(39)
tyranids
(15)
votd
(1)
warhammer 40k
(12)
wip
(8)