Commit 37183376 authored by Leigh B. Stoller's avatar Leigh B. Stoller

TEMP HACK. Check for a missing identity file on password updates and

regen the ssh key if its missing. If there is still an authorized_keys
file, cat the new identity.pub onto the end of the authorized_keys
file.
parent 8e0c867b
......@@ -205,8 +205,15 @@ else {
if (system("$USERMOD $user -c \"$fullname\" ")) {
fatal("Could not modify user $user on local node.");
}
#
# Temp Hack!
#
FirstTime();
}
exit(0);
#
# Make user account on control node. We do the password setup as separate
# step since thats easier than trying to do both via ssh.
......@@ -290,6 +297,13 @@ sub FirstTime()
$dossh = 1;
}
#
# Check for missing identity file
#
if (! -e "$HOMEDIR/$user/.ssh/identity") {
$dossh = 1;
}
#
# The rest of this needs to be done as the user, so fork a child.
......@@ -310,11 +324,22 @@ sub FirstTime()
if (system("$KEYGEN -P '' -f $HOMEDIR/$user/.ssh/identity")) {
fatal("Failure in ssh-keygen");
}
if (system("/bin/cp $HOMEDIR/$user/.ssh/identity.pub ".
"$HOMEDIR/$user/.ssh/authorized_keys")) {
fatal("Copying over $HOMEDIR/$user/.ssh/identity.pub ".
"to authorized_keys");
if (! -e "$HOMEDIR/$user/.ssh/authorized_keys") {
if (system("/bin/cp $HOMEDIR/$user/.ssh/identity.pub ".
"$HOMEDIR/$user/.ssh/authorized_keys")) {
fatal("Copying over $HOMEDIR/$user/.ssh/identity.pub ".
"to authorized_keys");
}
}
else {
if (system("/bin/cat $HOMEDIR/$user/.ssh/identity.pub >> ".
"$HOMEDIR/$user/.ssh/authorized_keys")) {
fatal("Catting $HOMEDIR/$user/.ssh/identity.pub ".
"to authorized_keys");
}
}
if (defined($user_pubkey)) {
system("echo \"$user_pubkey\" >> ".
"$HOMEDIR/$user/.ssh/authorized_keys");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment